Rivian Automotive Inc. on Tuesday raised its full-year production forecast after it posted a narrower second-quarter loss and significantly improved revenue.

The company reported a net loss of $1.2 billion compared with red ink of $1.7 billion during the same quarter last year. Revenue tripled to $1.1 billion.

The company also said it expects a smaller operating loss in 2023, but shares fell about 2.5 percent in trading after the bell.

Rivian now expects to make 52,000 vehicles this year, up from its previous forecast of 50,000.

The Irvine, California-based company cited “progress we have seen to date on our production lines, the ramp of our in-house motor line and the supply-chain outlook” for its revised expectations.

The higher production forecast comes after the EV maker delivered 12,640 vehicles in the April-June period, beating analysts’ estimates of 11,000, a positive sign for the company that had struggled to ramp up production because of supply chain issues fueled by the pandemic and Russia’s invasion of Ukraine among others.

Rivian also reported a major improvement in its gross margins, which stood at negative 37 percent in the quarter, compared with negative 81 percent in the first quarter and now expects a $100 million improvement to its operating loss this year at $4.2 billion.

The Amazon.com-backed company expects demand for its electric pickups and SUVs to remain stable even in the face of higher borrowing costs.

Analysts believe Rivian’s efforts to build its own drive unit, which comprises motors and electronic components, with the aim of lowering dependence on suppliers, will help the company stand out among smaller EV startups.

As the company grew deliveries and built efficiencies in the April-June quarter, it posted an adjusted loss of $31,595 per vehicle sold, compared with a loss of $67,329 in the previous three months.

Cash and cash equivalents at the end of the quarter were $9.26 billion, compared with $11.57 billion, as of December 2022.

Bloomberg and Automotive News contributed to this report.