U.S. oil and gas producer Hess Corp. posted its first profit in about four years that also easily beat analysts’ estimates as it sold oil at higher prices and managed to slash costs by 62%.

New York-based Hess has not reported a profit since 2014 and has been under intense pressure from shareholders after many of its peers turned profitable following the recovery in crude prices.

Hess said on Oct. 31 its average realized oil selling price, including hedging, was $66.08 per barrel in the third quarter, up from $46.97 per barrel in the year-ago quarter. That helped offset a 7% drop in production.

The company’s total costs and expenses in the quarter dropped by 62% to $1.61 billion.

Net income attributable to Hess was $52 million, or 14 cents per share, in the third quarter ended Sept. 30, compared with a loss of $624 million, or $2.02 per share, a year earlier.

On an adjusted basis, the company earned 38 cents per share, compared with projections for just breaking even, according to Refinitiv data.

Hess shares rose 6% to $60.34 in premarket trading.