NEW YORK (AP) — Bank of America’s earnings fell 20 percent in the second quarter, the bank said Monday, as historically low interest rates dented the bank’s profitability, just like it had done for its major competitors.

The Charlotte, North Carolina-based banking giant earned $3.87 billion, or 36 cents per share, before dividends to preferred shareholders. That’s down from $4.8 billion, or 43 cents per share, in the same period a year earlier.

The results still beat analysts’ expectations, however. Analysts polled by FactSet expected the bank to earn 33 cents per share. Revenue at the nation’s second-largest bank by assets fell to $20.4 billion from $21.96 billion.

“We had another solid quarter in a challenging environment,” CEO Brian Moynihan said in prepared remarks.

BofA, like Wells Fargo and JPMorgan Chase, continued to struggle in the face of low interest rates. The bank’s profit margin on loans fell to 2.03 percent from 2.37 percent from a year earlier, mirroring similar drops at Wells Fargo and JPMorgan.

The ultra-low interest rates led the bank to take an accounting charge of $1 billion in anticipation of more customers refinancing their mortgages at lower rates, which will mean lower earnings for the bank in the future. The charge was a large component of BofA’s drop in profits this quarter.

BofA’s consumer banking division, by far its largest business by revenue and profit, earned $1.72 billion, up from $1.66 billion a year earlier. Loans and deposits increased. BofA said it had the largest number of U.S.-issued credit card accounts since 2008.

Also like its competitors, Bank of America saw a spike in trading revenue following the vote by Britain to leave the European Union. Revenue in BofA’s global markets division rose 12 percent to $3.7 billion. Fixed income, currency and commodity revenue jumped 22 percent.

As it has done for several years, BofA cut expenses sharply in the quarter by closing branches and reducing head count. The bank had 210,516 employees as of the end of the quarter, down roughly 6,000 from a year ago. The number of branches fell to 4,681 from 4,789. Total expenses fell roughly 3 percent year over year.

Bank of America’s shares rose 18 cents, or 1.4 percent, to $13.85 in early trading.