We’ve all experienced the unpleasant effects that come along with not getting enough sleep. But not catching quality zzz’s can do more than leave you feeling tired and grumpy. In fact, sleep disturbances could be a warning sign that a person’s suicidal thoughts may be getting worse.

A new Stanford University study found that a fluctuation in the times young adults fell asleep and woke up affected how severe their suicidal thoughts would be in the days or weeks to come.

Read: Surprising Sleep Facts: How Poor Sleep Hurts You, According To Science

Unlike some factors that increase a person’s risk for suicide, such as being white or a male, a change in your sleep habits are able to be modified, the study authors point out.

"Sleep disturbances stand apart from other risk factors because they are visible as a warning sign, yet nonstigmatizing and highly treatable. This is why we believe they may represent an important treatment target in suicide prevention,” study author Rebecca Bernert said in a statement. Bernet is a suicidologist and assistant professor of psychiatry and behavioral sciences at Stanford.

In the small study, published in the Journal of Clinical Psychiatry, Bernert and her colleagues looked at self-reported sleep data from 50 undergraduate students, ages 18-23. All of the participants indicated they previously attempted suicide or had thoughts about killing themselves.

For one week, the participants wore watchlike devices that allowed the researchers to measure their quality of sleep. The findings revealed that those who fell asleep and woke up at varying times were more likely to experience suicidal symptoms at the 7-day and 21-day marks. This relationship was still true, even after the researchers accounted for how severe a person’s depression and their suicidal symptoms were, as well as their substance use habits.

"Sleep disturbances and suicidal ideation are both symptoms of depression, making it critical to disentangle these relationships and evaluate factors that stand alone to predict risk," Bernert said.

Read: Depression Symptoms And Diabetes: Poor Sleep In Diabetics Linked To Mental Health Condition

Currently, the team is carrying out two trials to investigate how non-medication insomnia treatments impact suicidal thoughts.

"Treatments tested for suicidal behaviors are alarmingly scarce in comparison with need and remain mismatched to the acute nature of a suicidal crisis," she said.

While suicide can affect anyone, it is especially prevalent among young adults aged 18-29 and is the second leading cause of death among that age group, according to the Centers for Disease Control and Prevention. Other groups which have shown more instances of suicidal behavior include American Indians, those who live in rural communities, and active or retired military personnel.

See also: Tricking Your Mind Into Falling Asleep: Placebo Eases Insomnia Symptoms, Review Says

Carrie Fisher Causes Of Death Released; What Is Sleep Apnea And How Can It Affect Your Health?