These days a lot of us are suffering from a lack of shut-eye. According to the Centers for Disease Control, around one third of our population gets less than seven hours of sleep a night.

It makes sense that folks with the most stressful jobs would be one group having a tough time getting a good night’s sleep. But a new study shows there’s more to it. Having too few demands on the job, or being disengaged from work responsibilities, can also keep you awake at night. What’s the answer?

It turns out that a secret to getting enough ZZZ’s is the Goldilocks principle — getting it just right — working at a somewhat demanding job and feeling you have some degree of control over your working conditions.

“ ”

Too much stress at work can ruin your sleep, but so can having too few demands on the job, and feeling disengaged from your work responsibilities.

— “The findings move beyond the previous narrative that job demands should be minimized as much as possible to protect worker’s health,”senior study author, Soomi Lee, an assistant professor in the University of South Florida’s School of Aging Studies, said in a press statement. “The previous knowledge that demanding work degrades sleep may be overly simplistic.”

Poor sleep has been linked to numerous health issues including cardiovascular disease, dementia and early death. It’s the reason why the University of South Florida authors say they were interested in addressing and identifying factors that contribute to poor sleep, including job-related demands.

To find out why workers are tossing and turning, they analyzed data from a past study that included nearly 3,000 employed adults, evenly divided between genders, with an average age of 48 years. Around half of the participants had a college degree from a four-year college.

People in the study had been asked about five aspects of their jobs: intensity, role conflict, work overload, time pressure and interruptions. They were also queried about their daytime alertness and about the quality of their sleep — how long it was and how easy it was for them to fall asleep, and how regular and satisfying it was.

They found that people sleep best when they enjoy moderate job demands and have adequate control over their work. This includes the opportunity to give input on work tasks, make decisions about one’s work environment and learn new tasks on the job.

“Based on these findings, it will be important to examine whether and how changes over time in job demands and control are associated with changes in sleep health,” Lee concluded.

Even though we may not always be able to control our work situation, we can do something about our sleep environment. Sleep experts suggest:

  • Going to bed at the same time each evening
  • Keeping your bedroom dark and quiet at bedtime
  • Avoiding caffeine late in the day
  • Creating rituals that pave the way for sleep (for example, taking a warm bath and reading a book)
  • Listening to certain kinds of music before bed
  • Studies have also shown that people can improve their sleep patterns by keeping a gratitude journal, using meditation and letting go of grudges by practicing forgiveness.

The study is published in Sleep Health.