As if the cramping and unpredictable mood swings weren’t bad enough, periods can also bring on bloating and bowel issues, ranging from constipation to diarrhea (sexy, we know!).

So why does your digestive system go crazy during that time of the month? We tapped Raquel Dardik, M.D., clinical associate professor of gynecology at NYU Langone Medical Center, to get some answers.

You’re not imagining things if you tend to feel bloated and constipated right before you get your period. “During the second half of the menstrual cycle, your body is making more progesterone, which happens after you release an egg,” Dardik says. That’s a good thing, but it comes with a frustrating side effect: “Progesterone slows down contractions of the bowel, so it slows down how quickly food and gas move through. Everything slows down and backs up, so you feel bloated and constipated.”

To add insult to injury, once your period starts, some women find themselves dealing with the opposite problem for the first day or two: diarrhea. “The diarrhea and cramping is a double whammy,” says Dardik. Two things are likely at play: Progesterone levels drop, which revs bowel contractions back up again so food may pass along at a speedier clip than before. The other cause is prostaglandins, hormone-like substances released by the uterus that trigger uncomfortable cramps. Some cause pain, but they also give people diarrhea.

Your Action Plan

The good news is that you’re not at the mercy of this monthly hormonal roller coaster. You can take steps to combat bloating and constipation by eating more fiber-rich foods, drinking more fluids, and exercising—all of which help keep you regular by decreasing bulky stools and softening them so they’re easier to pass, notes Dardik. “It doesn’t counteract progesterone, but it does decrease the symptoms,” she says.

If you’re dealing with diarrhea and don’t want to let it run its course, Dardik recommends taking an over-the-counter non-steroidal anti-inflammatory (NSAID) like ibuprofen or aspirin. These can help ease diarrhea, along with painful cramps, because they block prostaglandins. You can also take an over-the-counter anti-diarrheal such as Imodium.

If your symptoms are truly unbearable, you may consider talking to your doctor about birth control pills: As one of our expert OB/GYNs explained, women taking them typically do not experience these issues because the body’s hormone levels do not fluctuate as drastically. And take heart: Within a few days, your symptoms should disappear.