Space suits are notoriously heavy, cumbersome, and uncomfortable. To make matters worse, many upcoming manned space missions will force astronauts to stay in these suits for days at a time. And one of the simplest biological realities is also one of the biggest problems: What do astronauts do when they gotta go?

Designing an in-suit space toilet is complicated when it comes to space, where human excrement is unconstrained by the rules of gravity. It can also be dangerous; waste that isn’t properly dealt with can be life-threatening to astronauts caught in an emergency. Right now, astronauts use diapers (a rather low-tech solution for billion-dollar space missions), but NASA knew there had to be a better way. Enter the Space Poop Competition, announced in October 2016. The open competition asked entrants to conceive of a design that could handle urination, menstruation, and defecation for an astronaut cooped up in a suit for six days. All in all, about 20,000 people from around the world answered the call, submitting more than 5,000 ideas to help astronauts poop. And this week, the agency announced the three winning designs.

The $15,000 first prize went to Thatcher Cardon, a family physician and in-flight surgeon for the U.S. Air Force based at the Laughlin Air Force Base in El Rio, Texas. “It seems like everybody has been interested in the problem peripherally,” Cardon says. “Even in medical school we studied it a little bit. But I never imagined that I’d be this involved.” He envisioned his design while lying on his couch, and prototyped it with help from his family, sourcing materials from craft stores, thrift shops, and hardware stores. To get his ideas across, he hacked together prototypes using everyday materials, like tubes, hoses, plastic bottles, and springs.

Cardon’s design does something novel: It removes the waste from the space suit completely. It’s an airlock hatch, located on the crotch of the space suit along with what he calls an “introducer” system–an easy way to insert objects into the suit that can handle waste elimination. That includes an inflatable bedpan, a pee cup connected to a suction bag, a more traditional diaper, and a hygiene wand for whatever’s left over.

Unsurprisingly, the system was inspired by Cardon’s medical experience. Minimally invasive procedures–like laparoscopy or arthroscopy–enable surgeons to remove a patient’s spleen through a small hole, or change a heart value through a catheter in the leg, he says. So instead of thinking about storing poop, the airlock gives astronauts a way to remove it entirely. Cardon’s inflatable bedpan, for instance, collapses around the feces, which can then be removed through the airlock.

This kind of valve hasn’t been used in a space suit before, and Cardon thinks that it’ll have broader applications beyond just human waste. “You can do all sorts of things that haven’t been imagined yet through that airlock,” he says. “When we start spending a lot of time in space suits, we probably want to have access to other parts of our body as well.”

“When we start spending a lot of time in space suits, we probably want to have access to other parts of our body as well,” Cardon says.

Second prize went to a three-person team that calls itself the Space Poop Unification of Doctors (SPUDs), composed of environmental engineer Stacey Louie, dentist and artist Katherine Kin, and doctor Jose Gonzales. Their solution uses air to push waste away from the body, and then store it in the suit. Third prize, called SWIMSuit—Zero Gravity Underwear, is a form-fitting garment that looks like something you might wear surfing. Created by product designer Hugo Shelley, it uses a catheter and a system that compresses and sanitizes feces.