NEW YORK (AP) — Bank of America’s earnings fell 20 percent in the second quarter, the bank said Monday, as historically low interest rates make it less profitable to make loans.

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 beat analysts’ expectations. Analysts polled by FactSet expected the bank to earn 33 cents per share. Revenue 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.

The ultra-low interest rates led the bank to take a 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.

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.

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.

Bank of America’s stock edged up 0.5 percent in pre-market trading.