Oilfield services giant Halliburton Co. posted its third straight quarterly loss July 20 as it took a $2.1 billion impairment charge amid a slump in oil prices and the resulting collapse in drilling by North American customers.

Demand for drilling services and oilfield equipment offered by Halliburton and rivals Schlumberger and Baker Hughes sank after oil prices collapsed in March. U.S. crude futures were trading around $40 per barrel July 20, at the bottom end of the range of what most producers need to turn a profit.

Many smaller oilfield service firms, including fracking provider BJ Services and sand provider Hi-Crush, have filed for bankruptcy since the price rout began.

Houston, Texas-based Halliburton reported a net loss of $1.7 billion, or $1.91 per share, in the second quarter ended June 30, compared with a profit of $75 million, or 9 cents per share, a year earlier.

Shares of the company rose 2.7% in premarket trading to $13.08, as market analysts praised its better-than-expected free cash flow and aggressive cost cutting.

“We believe 2Q results reflect quicker and potentially stronger cost reductions,” wrote analysts from Wells Fargo in a note following the earnings release.

The company reported free cash flow of $456 million, significantly topping analysts’ expectations.

Halliburton last quarter slashed its quarterly dividend by 75% after cutting its capital spending forecast to half, sweeping workforce reductions and executive pay cuts. It is targeting other cost reductions of about $1 billion to shore up cash.

“Halliburton is charting a fundamentally different course,” CEO Jeff Miller said in a release. He praised the company’s performance in a “tough market.”

The company posted a surprise adjusted profit of 5 cents per share as a result of the cost cutting measures. Analysts had expected a loss of 11 cents, according to Refinitiv IBES data.