When you can’t sleep, you’ll probably feel groggy or cranky the next day. You might have trouble concentrating at work, too. If you get less than six hours of sleep for many nights, you could be at an increased risk for infections, depression, anxiety, weight gain, diabetes and high blood pressure.

For healthy adults, experts recommend seven to nine hours of sleep each night. To improve the quantity and quality of your sleep, consider trying the tips below.

1. Establish Regular Sleeping and Waking Times

By going to bed and getting up at the same time each day, you’ll find it easier to fall asleep, and you’ll stay asleep longer. You might even find that you’re able to wake up without an alarm clock! It’s important to set aside at least eight hours of time for sleep, and you should keep your regular sleeping and waking times on the weekends, too. To make it easier to find your ideal sleep schedule, you might want to experiment with going to bed 20 minutes earlier each night. Once you find a sleeping time that allows you to wake up feeling refreshed, use that time as your nightly bedtime.

2. Keep Your Bedroom Dark and Cool

Light and temperature changes can cause you to wake up in the middle of the night. To keep your bedroom as dark as possible, you may want to consider buying room-darkening shades or curtains. Some people find that wearing a sleep mask over the eyes is beneficial, too. In terms of temperature, experts recommend 60 to 67 degrees Fahrenheit for the best possible sleep. As you prepare for the first stages of sleep, your body temperature decreases, and bedroom temperatures between 60 to 67 degrees may make it easier for your body temperature to drop. It’s important to use bedding that’s appropriate for the season. In the summer, using cotton sheets may keep you cooler than using polyester sheets, and flannel sheets are cozy for the winter months. You may want to use an electric blanket in the winter.

3. Avoid Electronic Devices Before Bedtime

To make it easier to sleep, experts suggest that you avoid using smartphones, computers and TVs for at least one hour before bed. Smartphones and computers emit blue light that makes it more difficult to fall asleep. Watching TV shows or playing video games before bed can be overstimulating, and you might find it harder to feel relaxed before bed. It’s particularly important to avoid watching TV in your bedroom. Doing so tells your brain that your bedroom is not a calm, relaxing place. If you use your smartphone as your alarm clock, it may be helpful to switch to using a basic alarm clock that you place on your nightstand. Many alarm clocks have functions that can simulate sunrise, slowly waking you over a period of 30 minutes. For optimal sleep, don’t bring your phone into your bedroom. Instead, place it on a table outside your bedroom, and allow it to charge overnight.

4. Create a Relaxing Bedtime Ritual

In the 30 to 60 minutes before your scheduled bedtime, it can be helpful to do a calming activity. For example, you might choose to read a few pages of your favorite book, or you could practice meditation. Taking a hot bath or shower may be soothing, and you could also consider listening to gentle music. Ideally, your pre-bedtime rituals should not involve smartphones, TVs or computers. If you choose to read a book, aim to read a paper copy instead of using an e-reader. You may want to experiment with several different activities to find the ones that are most effective for you. Once you find a relaxing group of activities, do the same ones each night, and keep them in the same order. This routine will act as a signal to your body that it’s time to get ready for bed.

5. Be Mindful of Your Meals

Since issues with digestion can keep you up at night, it’s important to avoid eating large or greasy meals within two hours of your bedtime. If you are feeling hungry before bed, aim to eat a small, low-calorie snack. Almonds, walnuts, bananas and oatmeal all contain compounds that may promote sleep. In terms of drinks, tart cherry juice has been shown to improve sleep quality, and chamomile or passionflower tea could be beneficial, too. Try to avoid caffeine and alcohol before bedtime. For the most restful sleep, you’ll need to enjoy all of your caffeinated beverages before 2 p.m. Although some people believe alcohol makes it easier to fall asleep, alcohol is a stimulant that could cause sleep disruptions during the night. Therefore, it’s best to stick with non-alcoholic beverages before bed.

6. Use Supportive Pillows and a High-Quality Mattress

Shapeless pillows and old mattresses can cause back and neck pain that may make it very difficult to sleep through the night. If you’re experiencing pain when you wake up in the mornings, check your mattress to see if it is sagging in certain places. If it is, this could be the source of your pain, and investing in a new mattress may help you sleep more comfortably. Similarly, you’ll want to choose pillows that are firm enough to provide adequate neck support, and you should purchase a new set of pillows every two years. Depending on how you sleep, you might enjoy pillows designed for side or back sleepers, and it can help to try out different pillow materials.

7. See a Medical Professional

If you’re still tossing and turning after trying the tips above, you may want to see a doctor or sleep specialist. Sleep apnea, menopause, depression, diabetes, asthma, heartburn and thyroid conditions can all disrupt sleep. You may need to have a sleep study to identify certain causes of disrupted sleep, and blood tests may be recommended. If a medical cause is identified, medications or devices worn during sleep may improve your overall sleep quality.