If you love coffee, you probably start drinking it the same time everyone else does: first thing in the morning. That’s why the line is always enormous at Starbucks on your way to the office! Turns out, that’s probably not the best time to drink your first cup of joe.

First, let’s be clear: coffee is—repeat, is—good for you. There’s substantial scientific evidence that coffee is incredibly good for your health. Everyone is different, of course, but numerous studies link coffee to decreased risk of:

  • Ÿ type 2 diabetes
  • Ÿ heart disease
  • Ÿ prostrate cancer
  • Ÿ heart failure

Coffee achieves this because it’s the number one source of antioxidants (those healthy compounds most often associated with fruits and vegetables) in the U.S. diet. That’s true not because coffee is especially high in antioxidants, but because Americans (83% of adults) drink so much coffee. When it comes to antioxidant sources, nothing else comes close according to researchers at the University of Scranton (Pa.)

So it should come as no surprise that a 2017 study out of the Keck School of Medicine of the University of Southern California found that those who drink 2 to 4 cups of coffee a day had an 18% lower risk of death than people who did not drink coffee at all.

These findings may sound promising if you like to start the day off with a fresh cup of java. However, other research has linked coffee to the stress hormone cortisol.

If you’re not familiar with it, cortisol has a bad reputation. It’s produced by the adrenal glands when we’re under pressure and our “fight-or-flight” response kicks in. High cortisol levels can wreak havoc on our bodies over time.

According to a study published in the  Journal of Clinical Endocrinology & Metabolism, cortisol is generally highest in the morning when we wake up. But as the day progresses, cortisol levels drop in a constant and regular fashion. They are at their lowest in the evening—unless you work at night, then the pattern is reversed.

If you drink your first cup of coffee early in the morning, especially right after you get out of bed, you’re not going to get the best benefits…

But here’s one of the more important things to understand about the study: If you drink your first cup of coffee early in the morning, especially right after you get out of bed, you’re not going to get the best benefits because coffee elevates your cortisol levels—right when you want them coming down—beyond what is needed to help you stay focused during the day. This is not good for you.

In fact, more often than not, early morning is one of the worst times of the day to drink coffee. In order to maximize the health benefits of coffee without unnecessary stress, your cortisol levels should be low.

So for most people, the best time to drink coffee—whether a barista prepares it at your favorite coffee shop or you grind your own beans at home—is when your cortisol levels are dropping, say, between 10 a.m. and noon.

Why the two-hour window?

Well, even though your cortisol levels continue to dip throughout the day, drinking coffee after midday isn’t a great idea because, according to WebMD, “caffeine can stay in our system for up to 12 hours.” This can cause some serious side effects including insomnia, excess belly fat, anxiety, and extreme fatigue—each huge sources of stress and major health hazards. The same holds for drinking coffee in the evening.

So in an ideal world, drinking 2 to 4 cups of coffee each day between 10 a.m. and noon is something to shoot for. It should keep your mood and energy level smooth. And you might live longer.

Confusing? Silly? Call it what you want, if it means you might celebrate more birthdays, drinking the right amount of coffee at the right time of the day is probably something to think about. We all know that eating fruits and vegetables is healthy, but what we drink and when we drink it is just as important.