Electricity—what a wonderful invention. Today, it’s difficult to image what the world would be like without it. But the introduction of electricity also brought with it what has become a prominent modern-day sleep disease—insomnia.

Before electricity, when the sun went down, people went to bed. There were no 24-hour stores or all-night television broadcasts. There were few activities taking place after dark. But with today’s 24/7 lifestyle, people regularly start their day before dawn, and extend it well into the evening. They can stay awake all night, if they choose. That may feel like a more productive life, but what it’s doing is causing a lot of additional stress. And that can lead to insomnia, causing them to lose out on deep, restful sleep for days at a time.

Your body needs deep sleep to function well; it needs deep sleep to survive. Without getting into the deep phases of sleep, your body doesn’t rejuvenate its cells and immune systems. Without deep sleep, your body’s neurotransmitters, neurochemicals, and hormones don’t function properly. Neurotransmitters are brain chemicals that tell the rest of your body how to function. Neurochemicals regulate the nervous system. Hormones are the actual messengers in your body; they control body functions ranging from emotions and mood to hunger and sleep to circulation and immunity.

Insomnia also has a nutritional connection. Food sensitivities can cause reactions such as headaches, rashes, and body pains that can have you tossing and turning at night. Perhaps more disruptive to sleep is when a food sensitivity causes inflammation and mucous buildup in the nasal cavity. That can make it tough to breathe through your nose, and forces you to breathe through your mouth. Mouth-breathing can lead to a host of problems with teeth and other oral structures.

There are three types of sleep disturbances related to many factors, but primarily diet:

Can’t fall asleep. When someone can’t fall asleep, it’s often because of what they ate or drank before bedtime. Dinner may have included rich, spicy, or heavy foods. Their late-night snack may have been loaded with carbs and lacking in protein. They may have had a cup of coffee too late in the day. They may have consumed too much alcohol.

But a racing mind can also keep a person awake. People who find it hard to let go of the day’s events often have trouble falling asleep. An imbalance in neurotransmitters can cause anxiety and keep the mind going long after the body is ready to call it a night.

Can’t stay asleep. When someone can’t stay asleep, it’s typically because of a hormonal or a blood sugar imbalance. Eating too much sugar too late in the day makes the blood sugar drop. To the body, that means there’s an emergency to be dealt with, so it wakes up. To avoid this, blood sugar must be stabilized throughout the day. Additionally, any late-night snacking must balance proteins with carbs. Instead of a bowl of sugar-laden cereal before bedtime, try half an apple with a tablespoon of almond butter instead. The second snack is much more stabilizing.

Frequent need to urinate because of a hormonal imbalance or a prostate issue can also cause a person to lose sleep. The can’t-stay-asleep problem comes when the person is unable to fall back asleep quickly.

Waking up tired. Sometimes, people sleep more than what seems an appropriate amount of time, and yet they still wake up tired. A person who is still groggy after eight hours of sleep may have: eaten too much protein with dinner, poor adrenal and/or thyroid function, imbalanced neurotransmitters, or a lack of oxygen while sleeping.

Whatever the cause of the sleep disturbance, the key is to address it sooner rather than later. Whether diet or other factors are the culprit, it’s time to find out. You’ve got nothing to lose and so much to gain—primarily, a good night’s sleep.