(Reuters) - United Airlines UAL.N raised its profit forecast for 2018 on Tuesday, as average fares and traffic both rose and it trimmed capacity expansion in the face of soaring fuel costs.

Shares of United rose as much as 4.2 percent in trading after the bell as the airline’s second-quarter profit also topped analysts’ estimates.

The third-largest U.S. airline forecast adjusted profit for the full year at between $7.25 and $8.75 per share, up from its previous range of $7.00 to $8.50 per share.

Bigger rivals Delta Air Lines Inc DAL.N and American Airlines Group Inc AAL.O have both cut their full-year earnings forecasts in light of rising oil prices.

The Chicago-based carrier cut its plans for capacity growth for the year to a rate of between 4.5 percent and 5 percent, a company spokesman said. It had previously forecast a range of between 4.5 percent and 5.5 percent.

The company said net income fell to $684 million, or $2.48 per share, in the quarter ended June 30 from $821 million, or $2.67 per share, a year earlier, hit by an already-flagged $105 million write-down of the value of its Brazil routes.

On an adjusted basis, the airline earned $3.23 per share, beating analysts’ estimates of $3.07, according to Thomson Reuters I/B/E/S.

Total operating revenue rose 7.7 percent to $10.78 billion, while average fares rose 1.5 percent.

Fuel costs, which accounted for a quarter of United’s total costs, surged 43.2 percent, reflecting a steep rise in crude oil prices since early 2016.

United said it paid $2.26 per gallon for aircraft fuel on average, up from $1.63 a year earlier.

Shares of the airline have risen 7.7 percent this year, compared with a 13.9 percent fall in the S&P 500 Airlines index .SPLRCAIR.