Despite the fact that having too many morning cold brews makes you feel like your heart will explode, a study from PLOS Biology released Thursday shows that there’s an optimum amount of coffee you can drink to maintain a healthy heart. “We’ve disproved what doctors have told your grandma: Don’t drink coffee if you have a heart problem,” study co-authors Joachim Altschmied, Ph.D. and Judith Haendeler, Ph.D., tell Inverse.

Altschmied and Haendeler, both University of Dusseldorf biologists, explain that there is extensive previous research demonstrating the health effects of caffeine at a “physiologically relevant amount” — namely, four cups. “It’s known that four cups or more of coffee lowers the risk for heart attack, stroke,, and diabetes,” says Altschmied. Now, they know the reason why this happens: Caffeine can “push” a protein called p27 into the mitochondria, or energy powerhouses, of heart cells. This, in turn, can help those heart cells function more efficiently. In their experiments, Altschmied and Haendeler found this process had a time-machine effect: The mitochondria in caffeinated old rats performed as efficiently as mitochondria in the healthy younger rats.

There might also be more heart attacks, according to this study. GIPHY

They gave their animals a dose of caffeine equivalent to four cups of coffee for rats, then looked at their heart health. In “aged” rats that had received that dose, the mitochondria appeared to be revamped by the presence of p27. And when those rats were given researcher-induced heart attacks — which destroy heart cells — the caffeinated mice showed greater movement of endothelial cells, which can help heart rebuild blood vessels like arteries and protect against further cell death.

The team are optimistic that this mechanism could have implications for people recovering from heart attacks, but they are adamant that this research is still in its infancy. They’re also sure that there are some patients who shouldn’t be drinking caffeine to improve heart health. Patients with tumors, for instance should be wary, as any type of blood vessel growth can potentially help a tumor survive. They also emphasizes that popping caffeine pills isn’t a shortcut to better heart health.

“Don’t sit around being a couch potato swallowing caffeine pills. It’s important not to overdo it,” Altschmied adds.

But if you can handle four or more cups of coffee a day, this research seems to indicate that you’re doing your heart a solid.