Whatever it was that caused you to sweat, nightmares are no fun—and frequent bad dreams can cause health trouble, per Time. The good news is there are some ways you can potentially prevent them, and one of them has to do with something you might be doing right before bed. Read on to find out what common habit could be ruining your sleep. RELATED: If Your Dream About This, Call Your Doctor Immediately. If you eat late at night, you could be setting yourself up for a scare. “First of all, it’s important to clarify that light snacking before bed should not disturb one’s sleep drastically. Nightmares are typically linked to heavy pre-bedtime meals, especially those containing sugary treats, fatty foods, simple carbs, and spicy ingredients,” Po-Chang Hsu, Doctor of Medicine and a Medical Content Expert at SleepingOcean.com, tells Best Life. How so? “At least a lot of food (or high-calorie meals) means the body will spend too much energy trying to digest it instead of sleeping,” he explains. “This typically leads to decreased sleep quality, which may trigger nightmares.” A full stomach before sleep also leads to higher body temperature and metabolism, he says, noting, “These two aspects might cause increased brain activity during REM sleep, leading to nightmares.” While there is a correlation between heavy meals and nightmares, nightmares after eating a lot aren’t inevitable, Hsu clarifies. One 2015 study by the University of Montreal showed mixed results, with 9.5 percent of participants reporting a link between late eating and nightmares. That said, even if your late-night microwaveable meal isn’t causing monsters to chase you, there are still plenty of reasons to nix the habit. Hsu says heavy meals before bed can cause nighttime disturbances; while you’re trying to digest everything, it can be harder to achieve restful sleep. “Too much food (or certain meals) can cause acid reflux, leading to sleep disruptions,” he says. A good rule of thumb is to stop eating about three hours before you hit the sack, according to the experts at the Cleveland Clinic.ae0fcc31ae342fd3a1346ebb1f342fcb When you really need to nibble on something, have a snack that contains low glycemic carbs and protein, advises Brittany Lubeck, MS, RD, nutritional consultant at Oh So Spotless. “And foods that naturally contain melatonin and tryptophan may even improve sleep quality,” she says. Hsu suggests yogurt and fruits like bananas and grapes. “Grapes, in particular, contain melatonin, which is a natural hormone your body also secretes to help sleep,” he explains. Finishing your dinner early enough and still facing demons in the middle of the night? Per WebMD, nightmares in adults are usually spontaneous, but a few things, in addition to late-night eating, can contribute to their frequency. Certain medications are associated with nightmares, such as antidepressants, narcotics, and some blood pressure medications. WebMD also says that withdrawal from medications and substances, sleep deprivation, anxiety, depression, post-traumatic stress disorder, and certain sleep disorders can also trigger nightmares. Fortunately, if your nightmares are frequent and interfere with your everyday life, there are treatments. Those include medical treatment, stress or anxiety treatment, imagery rehearsal therapy, and medication, according to the Mayo Clinic. RELATED: If You’re Taking This Popular Supplement, It Could Be Causing Nightmares.