If you’ve ever had problems falling (or staying) asleep, you’re likely well-acquainted with using melatonin—a.k.a., the supplement form of your body’s sleep hormone to help you doze off.

But here’s something you might not know: There’s actually another supplement out there that could also help you get some sleep—in fact, your body might even be deficient in it already: magnesium.

According to Women’s Health Magazine, the mineral plays an important role in tons of bodily functions: metabolism, blood sugar regulation, bone health, and nerve and muscle function, among other things. It also plays a crucial role in sleep, too.

Here, a sleep doctor weighs in on what you need to know about magnesium, and why you might want to start using that instead of other sleep remedies (yep, melatonin, I’m looking at you).

So wait, magnesium really can help you sleep?

According to some evidence, yes, confirms W. Christopher Winter, M.D., author of The Sleep Solution and a board-certified sleep specialist at Charlottesville Neurology and Sleep Medicine in Virginia.

For one, magnesium is an important player in many of the steps that allow you to take protein and convert it into the chemicals that help you feel sleepy, explains Dr. Winter.

It also helps calm the nervous system down, helping it work more efficiently, and plays a role in muscle relaxation and nerve function, he says. (That’s why magnesium is often a supplement docs use to help people with managing symptoms of restless leg syndrome, says Dr. Winter.)

Magnesium also helps the body maintain levels of GABA (a.k.a., gamma-aminobutyric acid), a neurotransmitter that Dr. Winter notes is responsible for “turning off” wakefulness.

Magnesium can also help the body’s dopamine levels rise, which can improve your mood says Dr. Winter. And if migraines are keeping you up, well, they can help alleviate those too, according to the American Migraine Foundation.

That means magnesium is safe to take for sleep?

In essence, yes, says Dr. Winter. According to the National Institutes of Health’s Office on Dietary Supplements, the recommended dietary allowance (RDA) for magnesium when used for sleep or general health is 310 milligrams a day.

Dr. Winter backs this up by saying that a good, moderate dose of magnesium is about 100 to 350 milligrams, daily. That dose should be void of any side effects.

Follow Us @CountzPR on Facebook, Twitter and Instagram for Wellness News and More!