Wells Fargo, scrambling to cut costs and offset soaring legal expenses, plans to pull the plug on 800 more bank branches by 2020.

The planned closings, announced on Friday, will leave Wells Fargo (WFC) with about 5,000 branches. The bank closed more than 200 branches last year, but still finished the year with more than 5,800, the most in the United States.

On a conference call with Wall Street analysts, Wells Fargo execs pinned the closings on Americans' increasing preference for online and mobile banking.

"We will have as many branches as our customers want for as long as they want them," said John Shrewsberry, the chief financial officer.

But analysts also see a link to Wells Fargo's infamous legal troubles. The bank's litigation expenses more than tripled to $3.3 billion last quarter. The legal costs stem from the bank's fake-account debacle, investigations into pre-crisis mortgages and "other consumer-related matters."

Those mounting expenses have unnerved Wall Street. The bank plans to cut $2 billion in expenses this year and another $2 billion in 2019.

Related: Wells Fargo's legal troubles down out huge tax windfall

Another problem: Wells Fargo's branches likely aren't the profit machines they were before the scandal. The bank abandoned its notoriously aggressive sales goals following the revelation of 3.5 million potentially fake bank and credit card accounts.

In a statement to CNNMoney, Wells Fargo said it evaluates its branch network "solely on customer trends, market factors and economic changes."

Wells Fargo did not release an estimate of how many employees will lose their jobs as a result of the planned branch closings. The bank pledged to help employees "identify opportunities within Wells Fargo, as well as within the community."

Last month, Wells Fargo announced plans to share its tax cut windfall with workers and customers by raising its minimum wage to $15 an hour and giving 40% more to charities.

Before the scandal, Wells Fargo had been much more reluctant than rivals to close branches. Between 2012 and 2016, Wells Fargo only shut about 2% of its branches, according to brokerage firm CLSA.

By comparison, JPMorgan Chase (JPM) closed 9% of its branches over that span, while Bank of America (BAC) shuttered 15%.

That trend has shifted. Wells Fargo close almost twice as many branches in 2017 as JPMorgan, according to figures released on Friday.

Wells Fargo plans to shut another 250 branches this year.