Tesla said Wednesday that Model 3 production is on track to begin at its Shanghai factory by the end of the year — a critical milestone for the automaker if it hopes to continue to increase sales and avoid the high cost of shipping and tariffs.

The Gigfactory Shanghai “continues to take shape,” Tesla wrote in its quarterly earnings letter to shareholders. Machinery was moved into the factory during the second quarter in preparation for the first phase of production.

“Depending on the timing of the Gigafactory Shanghai ramp, we continue to target production of over 500,000 vehicles globally in the 12-month period ending June 30, 2020,” the company wrote.

That is a rosier outlook than the company provided just three months ago when it said that goal didn’t appear very likely. At the time, Tesla noted that it was “targeting” as many as 500,000 vehicles globally based on reaching volume production early in the fourth quarter. “However, based on what we know today, being able to produce over 500,000 vehicles globally in the 12-month period ending June 30, 2020 does appear very likely,” the company wrote in its first-quarter earnings letter posted April 24.

The production line at the factory in China will have a capacity of 150,000 units annually and will be a simplified, more cost-effective version of the Model 3 line at its Fremont, Calif. factory. Tesla previously said this second-generation Model 3 line will be at least 50% cheaper per unit of capacity than its Model 3-related lines in Fremont and at its Gigafactory in Sparks, Nev.

Tesla is counting on sales in China to continue its sales momentum.

“Given Chinese customers bought well over a half million mid-sized premium sedans last year, this market poses a strong long-term opportunity for Tesla,” the company said Wednesday.

Producing the Model 3 locally would reduce the costs of shipping and tariffs. However, that doesn’t remove every obstacle there.

Automotive sales in China have taken a hit over the past year. The first signs of a recovery were reported earlier this month when preliminary numbers from the China Passenger Car Association showed vehicle sales rose 4.9% to 1.8 million units in June from a year earlier. That’s the first increase since May 2018 for the world’s biggest market.