Do you dream of getting a good night’s sleep but always wake up bleary-eyed and cranky? Age might be partly to blame but tweaking lighting can help.

Sleep patterns tend to change with age, with older adults reporting more insomnia than younger adults. It can be harder to get a sound sleep as you age, but certain common habits exacerbate these changes.

Here’s one example: You awaken at 3 a.m. to get a glass of water, and while you’re up you grab your phone to check your email. Instead of lulling you back to sleep, the light bouncing off the screen tells your mind it’s time to rise and shine. You stay awake to surf the internet or go back to bed to stare at the ceiling, falling back to sleep just before your alarm goes off. Your day is shot.

Research shows that light and darkness play a key role in sleep patterns. By being mindful of this and taking some easy steps to correct your body’s natural rhythms, you can get a better sleep.

How Light Affects Your Body

Light affects your circadian rhythms, which are body changes that follow a 24-hour cycle. Controlled by your biological clock, your circadian rhythms influence hormone release, body temperature and sleep patterns.

“Light turns on wakefulness and turns off sleepiness,” says Mark Brown, MD, who is board-certified in sleep medicine and the author of “Smarter Sleep: Real Answers, Science Based Solutions, Healthier Sleep.”

In nature, the sun helps to regulate wakefulness and sleepiness, which are two opposite neurological states, Brown says. “Ideally, in nature, the sun goes down, it gets dark and we go to sleep,” he says.

In fact, if you were struggling with sleep and went camping in the wilderness, your body clock would likely get back into a more natural rhythm that waxes and wanes with sunrise and sunset, he says. You’d probably wake up in the morning and say, ‘This is amazing. I feel fantastic,'” he says.

However, artificial light, especially blue light, can throw off your body clock and affect your sleep and even your health. “The most dangerous light from a sleep perspective is blue light,” Brown says. “It’s the most wake-promoting.” That’s partly because blue light, which has a shorter wavelength than other types of visible light, is daytime light. During the day, blue light can help you pay attention, make you quicker to react and boost your mood. At night, though, blue light suppresses the production of sleep-inducing hormone, melatonin, which is made by the tiny pineal gland in the center of your brain.

Exposure to artificial light at night has also been linked to health problems, including heart disease and obesity, as well as insomnia and delayed sleep phase disorder, a sleep disturbance in which you have trouble falling asleep at your desired bed time. This disorder can leave you tossing and turning or delaying sleep for three to six hours each night, then sleeping for longer than you want to in the morning.

Light the Way to a Better Sleep

If getting a good sleep is a bit of a challenge for you, here are four ways to prevent light from hampering your rest and even to use it to your advantage:

1. Start your day off right with light. Getting your body into the right rhythm starts in the morning. “When you’re ready to begin the day, exposing your body to the sun will not only help alert the brain and set you in motion, it will also help you sleep later on,” the National Sleep Foundation states. Try to kick off your day with an hour of exposure to natural light, such as sitting in a sunny room or taking a walk outside. In winter, using a light therapy box is also an option, but the devices that really work are the more expensive, medical grade ones, so it’s best to use natural light if you can, Brown says. “Get your eyes open, get the shades up and feel the sunshine,” he says.

2. Wind down in the evening. Several hours before bedtime, turn off your computer, put away your smartphone and shut off the TV. Also consider enabling the night mode on your smartphone in case you grab it at 2 a.m. to check the time, Brown says. This dims the light emanating from your device at night. Research shows that the light emitted from screens causes melatonin suppression, says Richard Hansler, a physicist who has done research on light and melatonin. “Most people are not aware that simply exposing their eyes to light from light bulbs or TV and computer screens stops the body from making melatonin,” he says. In contrast, avoiding blue light for a few hours before bedtime allows your body to ramp up production of that sleep hormone. “By bedtime there will be plenty in your bloodstream and sleep will come easily and deeply,” Hansler says. The levels of melatonin in your body will then decrease as you get closer to wake-up time. “No more groggy mornings,” he says. You’ll be able to fall asleep faster and sleep more deeply.

3. Use the right light for bedtime reading. Studies have shown that reading a physical book can help you relax, which can help get you ready for sleep, but using the wrong reading lamp (or reading material) can create the opposite effect. For bedtime reading, choose a pleasant read such as a classic novel or lightly humorous memoir in physical, rather than electronic, form. In one study on sleep and light, participants who read a physical book took less time to fall asleep, had more restorative REM sleep, felt sleepier before bed and, after eight hours of sleep, were more well-rested and quicker to wake up than participants who read on an electronic device. If you want to read before bed, consider using a shaded lamp with a light bulb that filters out blue light. For example, the Good Night Biological LED Lamp & Light Bulbs are designed to be used at night. As you start to feel drowsy, flip off the lamp. Even if it doesn’t emit much blue light, leaving it on while you sleep can prevent you from sleeping deeply and can cause you to wake up more during the night.

4. Sleep in total darkness. For a good night’s sleep, keep your bedroom completely dark. Even small amounts of light can interfere with your sleeping patterns. One common culprit: slivers of light coming in through the curtains from a street light or your exterior security lights. Consider getting blackout curtains that can be pulled to cover your entire window to eliminate this source of light. If you use a digital clock or any other electronic that emits even a tiny bit of light, toss a cover over it while you sleep to completely block the glow. Or consider a simple sleeping eye mask, Brown says. And if you need a nightlight in the hall or bathroom to prevent falls, try to use one with a red bulb because this is the light wavelength “most conducive to sleep,” according to the NSF.

To make any of these lifestyle changes — and get them to stick — it’s important to make a plan and start small, changing one behavior at a time. Consider starting with the change that’s easiest for you and progressing to the ones you find more difficult.

Once you get into the habit of using these tips and tricks to light the way to a sound sleep, you should wake up refreshed, rather than cranky, in the morning.

Related Article: 7 Habits That Science Says Increase Longevity