When you wake up from a bad night’s rest, the first thing you generally do is grab a cup of coffee. It’ll help shake off the cobwebs and get you back to feeling a little bit closer to normal. There has even been research showing that, at least temporarily, coffee can offset the negative effects of sleep deprivation. But, as it turns out, this may not be exactly right. According to a new study, while coffee can help overcome a lack of sleep when a person is performing simpler tasks, it may not be of much help with more complicated ones.

Recently published in the Journal of Experimental Psychology: Learning, Memory, & Cognition, the new study was performed by Michigan State University’s Sleep and Learning Lab, led by psychology associate professor Kimberly Fenn. For the work, 276 participants were asked to complete two tasks: “a simple attention task as well as a more challenging “placekeeping” task that required completion of tasks in a specific order without skipping or repeating steps,” per MSU Today. The participants were then randomly assigned to either get sleep at home or stay awake overnight in the lab.

The next morning, participants were given either a 200mg caffeine pill (roughly equivalent to two cups of coffee) or a 200mg placebo before being asked to perform the same tasks as the previous day. They found that the sleep deprived participants that took the placebo underperformed on both tests based on their previous results. For the sleep deprived that were administered caffeine, researchers found that sleep impairment was counteracted for the simpler attention task, but the effect on the more complicated task was less apparent, noting that the caffeine “did not significantly affect placekeeping for most participants, though it did reduce the number of sleep-deprived participants who failed to maintain criterion accuracy.”

This, researchers suggest, show that “caffeine has limited potential to reduce procedural error rates in occupational settings.”

“Caffeine increases energy, reduces sleepiness and can even improve mood, but it absolutely does not replace a full night of sleep,” Fenn said. “Although people may feel as if they can combat sleep deprivation with caffeine, their performance on higher-level tasks will likely still be impaired. This is one of the reasons why sleep deprivation can be so dangerous… Our findings underscore the importance of prioritizing sleep.”

When combined with the findings from the previous research, this new study bolsters the idea that, while coffee can help you overcome a lack of sleep in some capacity, its effects are temporary and limited. There is simply no replacement for a good night’s rest. But for when more sleep is not an option, there’s coffee. And it tastes better anyway.

Zac Cadwalader is the managing editor at Sprudge Media Network and a staff writer based in Dallas. Read more Zac Cadwalader on Sprudge.