NEW YORK (AP) — Wells Fargo’s third-quarter profits took a beating this quarter, falling 18 percent, after the bank had to set aside about $1 billion for legal expenses related to its mortgage practices before the financial crisis.

The legacy from last decade’s housing bubble bit Wells at a time when the San Francisco-based bank is trying to move beyond its phony account scandal from last year and another more recent scandal tied to its auto lending business.

Wells Fargo said Friday that it earned $4.6 billion in the third quarter, or 84 cents a share, down from $5.64 billion, or $1.03 a share, in the same period a year earlier. The bank’s results missed the forecasts of Wall Street analysts, who were looking for the bank to post a profit of $1.02 a share, according to FactSet.

Investors, who saw Wells’ rivals report better-than-expected earnings over the past two days, dumped the stock. Shares were down 3.1 percent to $53.49 as of midday.

Wells Fargo’s expenses jumped in the quarter, mostly due to an additional $1 billion set aside for previously disclosed investigations into its pre-crisis mortgage practices.

Wells has been trying to move beyond the recent problems that have turned it from one of the banking industry’s most beloved brands into one of its most tarnished. The bank has acknowledged that its employees, fueled by unrealistic sales goals, opened as many as 3.5 million bank accounts without customers’ permission.

Wells also admitted that it sold auto insurance to auto loan customers who did not need it, and a significant number of those customers were unable to afford both their car loan and the insurance, which resulted in those cars being repossessed.

It’s not clear whether Wells’ reputational wounds have healed. Wells Fargo CEO Tim Sloan appeared in front of Congress earlier this month where he faced hostility from both political parties.

Under the weight of those scandals, Wells Fargo’s consumer banking division appears to have struggled. Wells Fargo’s community bank division had net income of $2.23 billion, compared with $3.23 billion in the same period a year earlier. Most of that was tied to the legal expenses, but the division’s revenue declined and so did its number of loans. In comparison, Bank of America, Citigroup and JPMorgan Chase all grew revenue and loans in their consumer banking businesses. Wells said the decline was also impacted by a drop in mortgage banking revenue as well.

Wells Fargo’s return on equity, which is a measure of how well a bank is performing with the assets it has, took a tumble this quarter as well to 9.06 percent from 11.6 percent. Wells Fargo for years had one of the highest and steadiest returns on common equity, but that was before the sales practices scandal.

Quarterly revenue was $21.9 billion, which also missed analysts’ forecasts of $22.38 billion.