Next time you’re wondering whether or not to have that extra cup of coffee, think about the health benefits it could offer you. According to the American Heart Association, coffee has been linked to a decreased risk of heart failure and stroke.

The research was presented at the American Heart Association’s Scientific Session this year. The researchers used machine learning and data from the Framingham Heart Study to examine what people eat and their heart health. The heart study has tracked the health of thousands of participants since the 1940s contributing to a wealth of data made available to researchers. The machine learning helped the researchers analyze the data and look at the connection between coffee consumption and heart health.

While the results could only give the researchers proof of correlation it does not necessarily mean there is any sort of causation linking the two. They found that consuming coffee was associated with a seven percent decreased risk of heart failure and an eight percent decreased risk of stroke compared to those who did not consume coffee. An association simply means that they found that participants who report drinking coffee also suffer stroke and heart failure less than those who report not drinking coffee. But to ensure that the results were correct, the researchers cross-checked the data with other studies. When they did this, using the data sets from the Cardiovascular Heart Study and the Atherosclerosis Risk In Communities Study, they found the same association.

While this finding is good news for coffee drinkers, it’s even better for other researchers who work on creating risk assessments for patients. The success of this machine learning experiment shows researchers could use the same method to possibly find other risk factors for heart failure or stroke. The researchers tried to run a similar analysis for the consumption of red meat but the connection was more difficult to validate because the definition of what counts as red meat varied between the Framingham Heart Study and those studies that were comparable.

Using a predictive model that factors in blood pressure, age and other health characteristics of participating patients and then adding coffee consumption, the researchers found that the prediction accuracy of the model increased by four percent. Thus, using the machine learning to add in new factors could help make the models more efficient and accurate.

Coffee has been said to have other health benefits as well. Coffee might also help protect people from Parkinson’s, diabetes, liver disease and other diseases and ailments, according to the Mayo Clinic.