(Reuters) - Wells Fargo & Co WFC.N is pulling back from retail banking in the U.S. Midwest, selling all of its branches in three states, as the bank embarks on a broader review of branch profitability across the country.

FILE PHOTO: A Wells Fargo bank sign is pictured in downtown Los Angeles, California, U.S. August 10, 2017. REUTERS/Mike Blake/File Photo

Flagstar Bancorp Inc FBC.N said on Tuesday it would acquire 52 Wells Fargo branches in Indiana, Michigan, Ohio and Wisconsin for an undisclosed amount. The branches have about $2.3 billion in deposits and $130 million in loans.

Wells Fargo, the fourth-largest bank by assets in the United States, will no longer have a retail presence in Indiana, Michigan and Ohio once the deal closes, spokeswoman Bridget Braxton said. It will continue to operate 48 branches in Wisconsin, as well as its commercial banking, wealth management, and retail brokerage business across the region.

The transaction is part of a strategy management laid out at San Francisco-based Wells Fargo’s investor day last month, involving the sale or closure of 800 branches by 2020.

The bank is working to make its operation more efficient and profitable in response to investor demands while also tackling legal and regulatory issues stemming from a sales scandal that erupted from its retail banking business in 2016.

Wells Fargo is targeting branches with slower-than-expected loan or deposit growth, as well as regions where it does not have enough market share to be competitive. For instance, its portion of deposits in Indiana’s Allen County, which includes Fort Wayne, fell to 29 percent in 2017 from 35 percent in 2016.

“We simply don’t have a major retail banking presence in Indiana, Michigan, Ohio and parts of Wisconsin,” Braxton said. “The prospect for growth in markets where we don’t have retail banking density drove this decision.”

Troy, Michigan-based Flagstar views the branches a little differently. Its news release on the deal highlighted that the branches it is acquiring have No. 1 market share position in Fort Wayne, as well as the Upper Peninsula of Michigan, and that the deal will double its customer base and provide an important source of liquidity.

“This was an opportunity not to be missed, not only to change our balance sheet, but to fundamentally change who we are,” Flagstar Chief Executive Officer Alessandro DiNello said on a call with analysts.

As Wells Fargo proceeds with the branch review, it may not be difficult to find other regional or community banks eager to buy branches for growth.

The Flagstar deal comes just weeks after Fifth Third Bancorp FITB.O said it would buy MB Financial Inc MBFI.O for $4.7 billion to expand its presence in Chicago.