The largest U.S. corporations are awash with cash and they are not afraid to spend it—on buying back their own shares.

S&P 500 SPX, -1.11% companies, determined to keep their share prices on a good footing during the turbulent market conditions at the start of the year, spent $161.4 billion on share buybacks in the first quarter of 2016. It’s the second-largest quarterly expenditure on buybacks after the record spent in the third quarter of 2007.

2007 was also the last year when corporate managers were as enthusiastic about buybacks as they are now.

See also:Here’s how investors are duped each earnings season

In the 12-month period ending March 2016, S&P 500 companies spent a record $589.4 billion on share repurchases according to S&P Dow Jones Indices, beating the previous year-over-year record of $589.1 billion set in 2007.

Don’t miss: Share buyback machine remains in overdrive and experts warn it will end badly

“The pace of buybacks was partially driven by companies supporting their stock during the opening downturn of the year, which coincidentally started in early February when many earnings lockups ended,” said Howard Silverblatt, senior index analyst at S&P Dow Jones Indices.

See also:Now even private-equity firms are buying back their own shares

Read:Carl Icahn’s $2 billion Apple stake was a prime example of investment inequality

The technology sector spent the largest amount at $34.7 billion, but the amount was approximately the same as in the first quarter of 2015. The largest increase in buybacks came from the health-care sector, which saw a 52.2% increase from the same quarter in 2015 to $30.6 billion.

The money spent by the top five companies accounted for nearly a fifth of the $161.4 billion: Gilead Sciences Inc. GILD, +0.01% spent the most at $8 billion, followed by Apple Inc. AAPL, -3.17% at $6.7 billion, General Electric Co. GE, -2.41% at $6.3 billion, Pfizer Inc. PFE, -0.51% at $5 billion and McDonald’s Corp. MCD, -1.03% at $4.3 billion, according to S&P Dow Jones Indices.

Total shareholder return, including dividends and buybacks, set a quarterly record of $257.6 billion over the first quarter and a 12-month record of $974.6 billion for the period ending in March 2016.

Also, the number of companies that buy back shares continued to rise. During the last quarter, 334 of the 500 companies participated in repurchases, compared with 318 in the fourth quarter of 2015 and 299 in the first quarter of 2015, according to S&P Dow Jones Indices.

Reducing share count allows companies to report higher earnings per share, and more than a fifth of the companies boosted their earnings per share by at least 4%, according to S&P Dow Jones Indices.

Read: Share buybacks may trigger the next leg down for U.S. stocks

Growing buyback amounts have accompanied a continued increase in corporate cash holdings. S&P 500 companies are sitting on a record $1.347 trillion of cash at a time when access to cheap credit is easy.

In a press briefing on Monday, Mohamed El-Erian, chief economic adviser at Allianz, said investors could almost feel sympathetic to companies given the size of their growing cash hoards.

Read:El-Erian says cash is more valuable than ever

“After the credit crisis of 2008, corporations learned to hoard cash for emergencies. But cash does not earn any interest or has zero return on capital. Large cash piles also attract activists. But if they deploy too early they will lose the optionality at a time when the economy is at a key T-juncture with two very different potential outcomes,” El-Erian said.