Imagine you're an astronaut. You're strapped into your seat wearing a bulky spacesuit, waiting to be blasted through the stratosphere, when the unthinkable happens: You gotta use the restroom. That nightmare scenario actually happened to Alan Shepard, who, as part of the Freedom 7 mission, became the first American to walk in fly up into space on May 5, 1961.

Since his leg-crossing (and potentially dangerous) mishap, waste management has become a serious concern for NASA scientists, who have spent decades refining the technology to help prepare our brave men and women for Mother Nature's inopportune calls. Here's a brief history of taking leaks in space:

What happened to Shepard?
After more than three hours of lying on his back due to delays, with just minutes left until takeoff, Shepard told mission control he just couldn't hold it anymore. "Man, I gotta pee," he told Gordon Cooper, who was stationed at the nearby blockhouse. (Shepard had gorged on orange juice and coffee for breakfast.)

After some discussion, NASA's scientists concluded that it was probably safe for him to pee in his spacesuit once its electrics were temporarily switched off. According to Freedom 7 mission's post-flight debriefing, Shepard managed to avoid electrocuting himself (which would have been embarrassing for NASA, to say the least), but his suit's electronic biosensors short-circuited. It probably smelled pretty bad in there, too.

Why didn't scientists consider the problem beforehand?
Back in the '60s, space missions were considerably shorter. In fact, Shepard's entire flight was scheduled to last just 15 minutes before he was hit with delays.

How did NASA attempt to address the issue?
Scientists had a few ideas in mind. According to PhysOrg, one was to outfit space explorers with catheters, which as most people know are "extremely uncomfortable and greatly increase the risk of infection." Another, which was actually implemented during Gus Grissom's Mercury-Redstone 4 Mission, was to wear two layers of rubber pants to seal off the excrement from the rest of the spacesuit. (Nasty.)

A somewhat sustainable solution was reached for John H. Glenn's Mercury-Atlas 6 mission on Feb. 20, 1962, when he was outfitted with a condom-like device that was connected via a tube to a storage container. Glenn used it; it worked. This modification persisted throughout the Apollo missions of the late '60s, in which Neil Armstrong and Co. wore "urine and fecal containment systems" underneath their spandex trunks.

Do astronauts still use tubes?
Not anymore. Since the '80s, NASA has been outfitting its men and women with what are essentially high-tech diapers. During 1983's Challenger mission, astronauts wore Disposable Absorption Containment Trunks, or DACTs. They slide on like bike shorts, and have sodium polyacrylate powder woven into the fabric, which can absorb up to 1,000 times its own weight in water.

Today's astronauts, though, wear Maximum Absorbency Garments — MAGs for short. (Former astronaut Lisa Nowak was said to be wearing a pair when she attempted to kidnap U.S. Air Force Captain Colleen Shipman back in 2007 in order to avoid pit stops.) The official brand was called Absorbencies, although the company has since folded. NASA still owns a stockpile of a few thousand of the super-absorbent MAGs, which comes in handy during space walks that can last up to eight hours at a time.

And don't forget that astronauts re-entering Earth's atmosphere are mandated to drink a half gallon of salty water in order to stay hydrated. According to the Chicago Tribute, "The body retains less water in zero gravity; if astronauts didn't replenish their fluids, they might faint when they returned to Earth's gravity."