German carmaker Volkswagen posted a forecast-beating 23 percent rise in underlying quarterly operating profit on Wednesday, even as difficulties conforming to new anti-pollution rules cloud the sales outlook for passenger cars.

A 5.5 percent rise in vehicle sales helped lift second-quarter operating profit before special items to 5.58 billion euros from 4.55 billion a year-earlier, compared with analyst consensus for 4.98 billion in a Reuters poll.

Earnings were however hit by a 1 billion euros fine for its diesel cheating and a further 600 million euros hit for legal expenses, VW said.

“These are solid numbers despite the legal expenses,” NordLB analyst Frank Schwope, who has a “Buy” rating on VW, said on Wednesday.

Despite confirming its outlook for a full-year adjusted operating margin of between 6.5 percent and 7.5 percent, Volkswagen warned that sticking to its financial targets will be a challenge.

After special items, VW said it anticipates that its operating return on sales will fall “moderately short.”

Volkswagen shares were down 2.8 percent in early trade, the biggest faller on the blue-chip DAX index, which was trading 0.2 percent lower.

In June, VW warned that production of up to 250,000 cars will be delayed as it struggles to adapt its vehicles to a new anti-pollution test, the Worldwide Harmonized Light Duty Vehicles Test Procedure (WLTP).

“We cannot rest on our laurels because great challenges lie ahead of us in the coming quarters especially regarding the transition to the new WLTP test procedure,” Chief Executive Herbert Diess said in a statement.

“Growing protectionism also poses major challenges for the globally integrated automotive industry,” he added.

After special items, which included 1.6 billion euros related to VW’s diesel emissions test cheating scandal, group operating profit dropped by 13 percent to 3.95 billion euros.

Rival carmaker Daimler and supplier Valeo cut their outlooks citing headwinds from the introduction of new stringent emissions standards and a slowdown in growth as a trade war and tariffs hamper global trade.