Popsugar: One of the more surprising side effects of taking melatonin? Nightmares. Here’s why they happen — and what you can do to get a more peaceful night’s sleep.

If you’ve had terrifying dreams while taking melatonin, you’re not alone. Melatonin can help you fall asleep faster, but according to Lisa Medalie, PsyD, a board-certified behavioral sleep medicine specialist and creator of the children’s sleep app DrLullaby, it can also cause you to stay in the deeper stages of sleep longer, which could open the door for more vivid or intense dreams.

“Most people take melatonin because they are experiencing difficulty falling asleep, returning to sleep, or insufficient sleep,” Dr. Medalie told POPSUGAR. 

popsugar.com