DETROIT (AP) — Tesla is recalling more than 2 million vehicles to fix a defective system that’s supposed to ensure drivers are paying attention when they use Autopilot.

Documents posted by U.S. safety regulators say the company will send out a software update to fix the problems.

The recall comes after a two-year investigation by U.S. auto safety regulators into a series of crashes that happened while the Autopilot partially automated driving system was in use.

Some were deadly.

The National Highway Traffic Safety Administration says its investigation found Autopilot’s method of ensuring that drivers are paying attention can be inadequate and “can lead to foreseeable misuse of the system.”