What made Apollo 13 such a great achievements was that it required astronauts and controllers to toss away years of careful planning. Instead, they were forced to improvise new plans, often with just minutes to spare, in a tense life-and-death battle.

The problems started long before the mission launched, when an oxygen tank destined for the service module was dropped on the factory floor. That damaged the plumbing, and no one noticed the problem when it was installed on the spacecraft some time later. As commander James Lovell noted in a recent NASA video, that wasn’t the only issue. “The mission was plagued by bad omens and bad luck from the very beginning,” he said. For instance, just prior to launch, the original crew was exposed to the measles, so Ken Mattingly was replaced by Jack Swigert.

The rest of the story is now ingrained into public memory, thanks in large part to the Apollo 13 film starring Tom Hanks. The crew quickly realized they not only wouldn’t be landing on the Moon, but that even getting back to Earth was going to be a challenge. Controllers figured their best shot at survival was to move from the disabled service module over to the LEM for the rest of the trip. That required the crew to quickly transfer guidance data from one module to another (in just 15 minutes), improvise a CO2 filtering system, and conserve power, among other hacks.

By the time the LEM reached Earth, the crew was freezing and exhausted, and Haise was suffering from a serious urinary tract infection. Despite making last minute corrections, the command module re-entered at a relatively shallow trajectory, which prolonged the re-entry from four to six minutes. Atmospheric ionization caused a radio blackout during those long extra minutes, so controllers couldn’t be sure if the astronauts were alive or dead.

When the module finally appeared under the parachutes and the controllers heard their voices, it was the culmination of a decade of work by NASA’s Apollo teams. “It was a question of getting this entire world geared and oriented to one single job — get the crew home,” said mission director Gene Cranz. “Teamwork was necessary, good leadership, initiative, thinking outside of the box when things went wrong — those were the three things that were absolutely necessary,” added Lovell.