The forecast and results raised hopes 2018 profits will hold up better than expected, despite obstacles such as rising raw materials costs, higher tariffs on bikes shipped to Europe and an aging customer base.

Harley’s shares opened higher on Tuesday and soared over 9 percent, recovering most of their losses since late June, when Trump attacked the company for planning to move production for European customers overseas. The stock closed up nearly 8 percent at $44.63.

The Milwaukee, Wisconsin-based company now expects its motorcycles segment operating margin as a percent of revenue to be about 9 percent to 10 percent in 2018, compared with the 9.5 percent to 10.5 percent it projected earlier.

The drop was due to higher steel and aluminum costs and a 25-percent retaliatory duty imposed by the European Union on the shipments from the United States. Those two factors together are estimated to cost Harley $45 million to $55 million this year.

The company expects to absorb half of the increased costs through disciplined business management.

“We are making every effort to mitigate the costs of those tariffs,” Chief Financial Officer John Olin told analysts on a conference call.

David Beckel, an analyst at Bernstein, reckons the 50 basis points fall in operating margin would translate into about $25 million in added costs, below Harley’s previous estimate of an up to $65 million hit from higher raw materials costs and the European tariffs. This will likely result in upward revisions to the company’s 2018 earnings, Beckel said.

Harley’s second-quarter net income fell to $248.3 million, or $1.45 per share in the second quarter ended July 1, from $258.9 million, or $1.48 per share, a year earlier. That exceeded analyst estimates of $1.34 per share, according to Thomson Reuters I/B/E/S.

The company retained its 2018 shipment forecast and said it would reveal plans on Monday about its strategy to train new riders, revive U.S. sales and grow its international business.

Trump’s restrictive trade policies have inflated Harley’s raw material costs and put it in crosshairs of a trade skirmish with the European Union. Last month, Harley unveiled a plan to shift production for European customers overseas to avoid the EU’s retaliatory tariffs, a move that Trump slammed.

On Tuesday, Chief Executive Matt Levatich stood by the company’s move, calling it “the best decision, given the circumstances.”

Trade tariffs have compounded the troubles of a company that has been grappling with an aging customer base, weak demand from younger buyers and discounts offered by its rivals.

Europe is Harley’s second biggest market after the United States. While U.S. retail sales fell 6.4 percent in the last quarter from a year ago, European sales were up about 4.3 percent year-on-year and accounted for half of international revenue.

The company did not say where it would shift the production for European markets. Harley has assembly facilities in India and Brazil, and is expected to launch an assembly plant in Thailand in September.