Putting things into space is a tricky art—and what goes up just might come down if it crashes into something else while it’s in orbit. Take NASA’s MAVEN, a spacecraft that’s been orbiting Mars for years. As Space.com’s Sarah Lewin reports, the craft was in danger of colliding with one of Mars’ moons until officials recently whisked it out of harm’s way.

The moon, Phobos, is one of two that circle the red planet. Larger than its counterpart, Deimos, it’s a lumpy, crater-pocked celestial body that revolves around Mars three times a day. Phobos also happens to be spiraling toward to Mars some six feet each century—in fact, scientists predict it will one day crash into the planet or be torn into rubble.

While it'll take an estimated 50 million years for Phobos to be no more, Phobos' nearness is the reason the trouble with MAVEN began. The spacecraft (Mars Atmosphere and Volatile EvolutioN) circles close to Mars’ surface, too, in a bid to learn more about its upper atmosphere and the ways it’s affected by solar weather. The craft has an elliptical orbit around Mars that coincides with both Phobos’ orbit and those of some other spacecraft multiple times a year.

Usually, there’s no danger of collision, since objects are on different parts of their orbit at different times. But in this case, it looked like MAVEN and Phobos were on a crash course. Since there’s not exactly a good way to push an entire moon out of orbit or slow it down, there was only one solution—speed MAVEN up.

And that’s just what NASA did, boosting its speed slightly—less than a mile per hour—with a rocket motor burn. In a release, the agency says that the craft will now miss Phobos by a scant 2.5 minutes. That seems like a close shave, but it will ensure the schoolbus-sized craft won't collide with a moon 10x14x11 miles in diameter.

Eventually, Phobos will get the last laugh. MAVEN will one day burn up in Mars’ atmosphere after its fuel is gone. But, of course, the Potato-shaped moon won’t be able to gloat forever. Scientists have already documented the first stages in Phobos’ slow disintegration—long grooves that are harbingers of the day when Phobos either tumbles into Mars or breaks apart. For now, though, it looks like the two can coexist…until their orbits put them in the same neighborhood once more.