Oil and gas producer Hess Corp. (NYSE: HES) posted a smaller-than-expected quarterly loss on July 25 as it raked in more money per barrel even as production fell, thanks to higher oil prices.

The company’s average realized price of crude oil jumped 36% to $62.65 per barrels, while production fell 16% to 247,000 barrels of oil equivalent per day (boe/d), excluding its operations in Libya.

U.S. crude prices topped $75 bbl at June end, rising more than 18% in the second quarter.

Hess said it earned $31 million from its exploration and production business on the back of better hedging of its contracts compared to a loss of $354 million a year ago.

The gains were also helped by higher production in the Bakken oil field in North Dakota, one of its biggest drilling projects.

The New York-based company has been investing heavily in an oil development project off the coast of Guyana along with oil major Exxon Mobil Corp. (NYSE: XOM).

Earlier this week, the companies said they expect one of the oil blocks in the project to contain about 25% more recoverable resources than initially estimated.

For the full year, Hess reaffirmed its output forecast of 245,000 boe/d to 255,000 boe/d, despite the sale of its Utica joint venture stake to a privately-held firm in June.

Total costs and expenses fell 5.4% to $1.54 billion.

Net loss attributable to the company narrowed to $130 million, or 48 cents per share, in the second quarter ended June 30, from $449 million or $1.46 per share, a year earlier.

Excluding one-time items, Hess lost 23 cents per share. Analysts on average were expecting a loss of 29 cents per share, according to Thomson Reuters I/B/E/S.

Shares of the company were marginally down at $64.98 in premarket trading.