In a lightly wooded area next to a running path. In a stranger’s bathroom. One hundred meters from the finish line.

These are just a few of the places runners we talked to have admitted to, well, crapping out, during a run. And we don’t mean figuratively: Yep, we’re talking about poop.

Harrison Glotman, 25, a 2014 New York City Marathon finisher, was training in an unfamiliar neighborhood when he realized he had to go, stat. Realizing his options were either drop a deuce on a residential lawn or go door-to-door and ask strangers to have mercy on his bowels, Glotman chose the latter. Luckily, the owner of the first house he tried took pity on him and offered him his bathroom.

Not all stories end with a flush, though. Kyle Simmons, 27, a 100-mile ultra marathoner, learned this the hard way at the Krispy Kreme Challenge, North Carolina’s premiere doughnut-eating race (yes, you read that right). After accidentally fertilizing his pants, he withdrew from the course in shame.

The Science Behind Our Bathroom Behavior

Yeah, it’s an awkward topic. (Go ahead and get out your giggles.) But anyone who runs or exercises regularly knows that unpredictable bowel movements are just part of the sport. They can come quickly without warning, slowly and painfully, or sometimes not at all.

So what’s really going on? Put simply, working out increases movement in your gastrointestinal tract, says Jeff Crespin, M.D., a gastroenterologist. “When you exercise, there’s more stimulation, which increases upper gastric motility,” Crespin says. “This carries over to the lower gastrointestinal (GI) tract.” Translation: The more you move, the more you poop.

Robynne Chutkan, M.D., a gastroenterologist and author of Gutbliss, says our GI tracts are muscular structures not unlike the large muscles of our arms and legs. “Exercise stimulates peristalsis—the series of concentric contractions that moves the products of digestion through our intestines, and for some people it can result in an urge to have a bowel movement as the intestinal contents reach the rectum—or the end of the road, so to speak.”

Running long distances also affects your circulation, which can prompt a desperate toilet search, fast. Essentially, during exercise, your visceral blood flow decreases, Crespin explains. This means less blood is directed toward the gastrointestinal tract so that more blood can be supplied to other parts of the body—namely, the peripheral muscles that are doing the running. “This decreased visceral blood flow strains the GI tract and can lead to diarrhea,” Crespin says.

The good news: “Most of the time, once a person stops running, their blood supply will return to normal within that same day,” Crespin says. “The human body is pretty resilient and rebounds pretty fast.”

While the panicky, “I-need-to-go-right-now” feeling is not uncommon mid-run, there’s also the equally scary alternative: not being able to poop at all. The reason for this varies. Sometimes a decreased blood supply can cause your body to “internally clamp down,” Crespin says.

Some people just have more robust motility and peristalsis than others, meaning their intestinal muscles work better, Chutkan says. Levels of hydration play a role too. “If you drink a lot of water, your stool is more likely to be soft and moist, finding its way to the rectum faster, making it easier to expel. Or maybe you’re dehydrated and have hard, dry stool that’s difficult to push out,” Chutkan adds.

On top of GI issues, race day jitters can contribute to your pooping woes in either direction, says Nancy Clark, R.D., a sports dietetics specialist. “If you’re already nervous about getting diarrhea during a race, that can exacerbate the problem.” On the other hand, it can also halt the process, since nerves can cause an increase or decrease in peristalsis depending on the individual.

How to Slow Your (Toilet Paper) Roll

While there’s no surefire strategy to avoid having to make an emergency pit stop on your next run, there are ways to lower your chances of any, ahem, accidents.

Chutkan recommends drinking an extra eight cups of of water a day (in addition to your normal intake) to induce regularity. Taking a daily fiber supplement like one tablespoon of ground psyllium husk (Metamucil) two weeks before a race or long run also helps move things along since a high-fiber diet can promote regular bowel movements Nutrition and Lifestyle in Relation to Bowel Movement Frequency: A Cross-Sectional Study of 20630 Men and Women in EPIC-Oxford. Sanjoaquin MA, Appleby PN, Spencer EA. Journal of Public Health and Nutrition, 2004, Apr.;7(1):1368-9800.. Just limit, or even avoid, your fiber intake a few days before a long run or race.

Gastric motility can also be prompted by drinking a warm liquid, Clark says. Consuming coffee, tea, warm water, or even warm oatmeal (and giving yourself some time to digest it) can prompt your body to naturally want to go No. 2.

Perhaps the biggest recipe for disaster is changing up your routine the day of a race, Clark says. If you want to try a new energy gel or supplement, experiment first during a training run to see how your body responds. On race day, eat foods you know your body responds to positively, and steer clear of any food with white flour that can leave you clogged up, like bagels, rice, and pasta, as well as fatty, greasy meals that are hard to digest.

Road Test: Runners Weigh In

OK, so we’ve heard from the experts in the medical room. But what about actual runners?

It may not exactly be scientific, but running blogger Eric Rayvid wakes up two hours before a long run or race, quickly eats breakfast, and drinks what amounts to 60 ounces of strong tea to ensure he gets quality time in the bathroom before heading out the door.

“Because I’m up so early, there’s the added benefit of getting to races super early and not stressing about getting into my corral or dropping something at bag drop on time,” Rayvid says.

Anne Mauney, M.P.H., R.D., a healthy living blogger and avid runner, swears by her morning cup of coffee before an endurance event. “Just make sure you drink it early enough that you have time to visit the facilities and take care of business before the race starts,” she says.

And Anthony Burdi, a well-seasoned marathoner and co-leader of The Rise NYC, recommends getting on a “morning pooping schedule.” Yes, really. “Do it first thing when you wake up, every day,” Burdi says. “On race day, you’ll be ready to let loose on the toilet well before you toe the starting line.”

But Still, Be Prepared

Because accidents do happen, running blogger Alison Feller (who has a self-proclaimed “finicky stomach”) carefully plans running routes lined with gyms, gas stations, and coffee shops that will usually let a desperate runner in to use the facilities.

And if no bathrooms are available? “I throw a wad of toilet paper in my shorts pocket in case there’s an emergency,” Feller admits.

Take these wise words to heart, and hopefully you’ll avoid a similar fate as Simmons, the soiled-sweats guy, in your future running endeavors. Oh, and one more piece of advice? As Jonathan Levitt, a marathoner and member of fitness community November Project so eloquently puts it: “Never trust a fart.”