On Tuesday, JP Morgan posted profits for the second quarter of 2015 that beat predictions from analysts. The reasons behind the higher-than-expected rise in profit include a drop in expenses, most notably legal and restructuring, a smaller tax bill, and higher merger advisory fees in its investment-banking sector.

In May, JP Morgan began a cost-cutting program designed to eliminate more than 5,000 jobs, which helped cut expenses by 6% to $14.5 billion, despite pressure to hire additional staff to help comply with new regulations. The company also reduced legal costs by 57% to $291 million, despite regulatory issues and a recent $136 million settlement regarding the company’s practices in the collection and sale of credit-card debt.

jp-morgan

Those cuts helped JP Morgan to offset a drop in trading revenue of 8.9% down to $4.51 billion. The mortgage sector of the bank also saw a 20% drop down to $584 million, with commercial profits also dropping 22% to $525 million.

However, thanks to a 17% increase in merger advisory fees to $466 million, JP Morgan’s corporate and investment bank profits increased 9.9% to $2.34 billion. This helped the quarterly net income to increase 5.2% from this time last year to a total of $6.29 billion, which equates to $1.54 per share. A year ago, shares were valued at $1.46, while analysts were expecting earnings of $1.44 per share for this quarter.

JP Morgan’s chairman and chief executive Jamie Dimon seems to be pleased with the company’s performance this quarter. In a press release, Dimon said, “We are focused on executing on our commitments and we’ve made good progress this quarter, including meeting regulatory requirements, reducing non-operating deposits, and adding to our capital. We are also on target to deliver on our expense commitments.”