Here’s some less than energizing news for coffee addicts. While most of us know that a coffee too late in the day can make it tough to fall asleep, we don’t necessarily understand why. Sure, it might seem like an easy equation—coffee gives us energy, and too much energy makes it difficult to sleep. But a study shows that the effects of caffeine on our bodies are actually more complex. 

Researchers at the MRC Laboratory of Molecular Biology and the University of Colorado found that caffeine actually affects our circadian rhythm. According to Science Translational Medicine, “caffeine—widely available, legal, and psychoactive—inserts a delay into the ~24-hour metabolic rhythm that keeps your body running in time with the world.” They found that drinking caffeine in the evening delays our brain’s release of melatonin, the hormone that makes us sleepy.

Since so many factors—from lighting to electronics use—can affect our sleep patterns, the researchers designed an experiment to eliminate as many variables as possible. They monitored five people under controlled conditions for 49 days. Before bed each night, volunteers were given either caffeine pills or a placebo, and exposure to different levels of light. 

Though the scientists actually found that bright light had the greatest impact on circadian rhythm, the effects of caffeine were significant, delaying subjects’ internal clocks by as much as 40 minutes. Though the study is unlikely to stop our caffeine consumption altogether, it’s definitely something to think about the next time we reach for that last coffee of the evening. 

[h/t: Science Translational Medicine]