California, the state with the second most foreclosures by volume, has passed one of the strongest laws in the country seeking to protect homeowners from improperly losing their homes.

The bill would bar lenders from moving forward with foreclosures while negotiating loan modifications, a practice known as dual tracking, and also allows lawsuits involving robosigning, or improperly processing foreclosure documents without review, to move forward. It also mandates a single bank representative for each borrower to streamline contacts.

California Attorney General Kamala Harris, who was a visible presence during the past year's foreclosure settlement with banks, which resulted in a $25 billion payout to 49 states, was an advocate of the bill.

“Passing these key elements of Homeowner Bill of Rights represents a significant step forward for struggling homeowners,” said Harris in a statement. “These common-sense reforms will require banks to treat California homeowners more fairly and bring more transparency and accountability to their practices in our state. Responsible homeowners will have a better shot to keep their homes.”

Opponents of the bill included mortgage industry groups, who said that new regulations would complicate the process and lead to excessive lawsuits. Legislators limited the protections to modifications on primary mortgages and only in owner-occupied properties with four or fewer housing units. Investors aren't protected.

More than 362,000 homes in California were in foreclosure or seriously delinquent on loan payments in March, according to the Mortgage Bankers Association. The number of homes in foreclosure is 3.3 percent of the state's loans, the 24th highest in the country. Lenders can foreclose on homes without going through courts, which speeds up the process compared with other states that require a judicial process.

Legislators approved the bill Monday, and Gov. Jerry Brown is expected to sign it into law within two weeks. Half of the states in the U.S. are considering changes to laws related to foreclosures, according to the Wall Street Journal.