(Veteran tech columnist Jon D. Markman publishes Strategic Advantage, a lively guide to investing in the digital transformation of business and society. Click here for a trial.)

Volkswagen spent $50 billion developing an electric vehicle to rival Tesla ( (TSLA) - Get Report). Then the German automaker discovered it had a software problem: It’s EVs didn’t work as expected.

Last week Volkswagen announced the recall of 50,000 of its ID.3 electric vehicles to fix software bugs. It’s an epic fail for a firm known for engineering excellence. It’s also a big opportunity for an American firm to clean up in response.

Investors should buy Nvidia ( (NVDA) - Get Report) to take advantage.

Tesla managers got software right from the beginning. Shares have risen 24,801% since the 2010 initial public offering. Along the way naysayers questioned everything from the viability of the EV market to Tesla priorities. Figuring out supply chains was way more important than fiddling with software, according to Tesla nonbelievers.

Years later the EV market has taken off and skeptics are arguing that is only a matter of time before the real car companies swoop in to take way the fledgling market. The failings of the ID.3 tell a different story. Mastering the supply chain doesn’t translate into EV superiority.

The Wall Street Journal noted on Wednesday that the first wave of ID.3s have been besieged by hundreds of software bugs. To make matters worse, the over-the-air system that is supposed to fix those glitches doesn’t work, either.

Ironically, Volkswagen’s supply chain prowess for internal combustion engine vehicles has become its EV weakness.

Power mirror and heated seats modules usually have their own microprocessors and static, task specific software applications. While these components plug-n-play easily with the computer on a 4-cylinder Golf, integrating with the centralized operating system of the ID.3 is proving more problematic. Hundreds of smaller distributed applications are causing endless glitches.

Volkswagen managers are scrambling for a quick fix. Thousands of ID.3s are being recalled. Technicians will manually upgrade the core software in February to VW.os version 1.2. A more mature version of the OS will not be ready until 2024. And even then the company plans to outsource 40% of the code development to outside suppliers and third party developers.

Unfortunately bad habits die slowly in legacy businesses, even when managers understand they must choose a different path.

Volkswagen is willing to work around software from its suppliers because it reduces costs. Managers have decided the economics of integration outweigh potential benefits of complete in-house solutions, like the Tesla OS.

And that brings me back to Nvidia.

Ten years ago, the Santa Clara, Calif-based company had a nice but unspectacular business. It made best-in-class semiconductors for PC and console gaming. Then Jensen Huang, chief executive officer, saw the light, literally.

The software Nvidia engineers developed to render light and physics for game graphics became the foundation for a new computing model based on artificial intelligence. Huang made the AI platform open source to entice academics and developers to buy-in. The strategy was a huge success, moving Nvidia hardware beyond gaming and into super computers and datacenters.

Meanwhile company researchers were building algorithmic models capable of solving complex problems, like autonomous vehicles. Huang showed off a AV computer in 2017 that was no bigger than a lunchbox but still capable of processing 320 trillion instructions per second, enough horsepower to process data from real time sensor streams, then push everything up to the cloud for further analysis. Hundreds of development partnerships followed.

Today Nvidia has 370 partnerships within the automotive sector. Company engineers are working on AV technology with Volkswagen, Audi, Toyota, Hyundai, Volvo and Mercedes.

I have never bought into the idea that legacy car companies would easily take market share from Tesla. They are hardware businesses. At its core Tesla is a software business; a classic example of the great digital transformation of business and society. Making cars, as difficult as that process can be, was always the easy part. Designing good software is hard work.

Nvidia is a hardware company that made the transition to AI software. And it is a great position to dominate big parts of the new automotive economy as its software/hardware solutions become of the brains of many of the world’s best brands.

Shares trade at 47x forward earnings and 23.5x sales. These metrics are reasonable given the size of the opportunity ahead. Nvidia has been trading sideways since September but should shake off its current funk before too long.