If you’re at high risk of having a heart attack, changing your diet can significantly lower your chances of heart disease. But how much can fruits and vegetables help someone who already has heart trouble?

Quite a bit, according to the latest study to investigate whether diet can reduce heart attack and stroke among those who are trying to avoid second or third events and are already taking medications to control blood pressure and cholesterol. In the largest-ever of its kind, published in the journal Circulation, a group of international researchers say healthy eating can have an added beneficial effect on the heart on top of the influence of heart-protecting medications.

“We encourage everyone to eat healthy. But especially high-risk patients, we want them to know: Take your medication, but modify your diet as well,” says lead study author Mahshid Dehghan, a researcher at the Population Health Research Institute in Hamilton, ON, in Canada, one of the centers involved in the study. “Some people think that if medication lowers their blood pressure, healthy eating doesn’t matter. We want them to know that this is wrong,” she says.

The study involved more than 30,000 adults aged 55 and older, all with a history of heart disease, stroke, or diabetes with organ damage and living in 40 different countries. All were enrolled in one of two different drug trials to test the effectiveness of blood-pressure medications. As part of the trials, the patients answered detailed questionnaires about their lifestyles, including diet: How often did they typically eat fish? fruits and vegetables? nuts? red meat? foods that had been deep-fried, or contained trans fats? They were also asked about behaviors that have been linked to heart disease such as smoking, alcohol consumption and lack of physical activity. Based on their responses, Dehghan and her colleagues assigned each participant an overall diet-quality score that reflected the composite quality of his food intake.

Five years later, it was clear that participants with diet-quality scores in the top 20% experienced far better heart health than those in the bottom 20%. They enjoyed a 19% drop in their risk of stroke, a 14% reduction in the risk of heart attack, and a 35% reduction in the risk of death from any heart-related cause. And these effects remained consistent among those who did and did not take medication, and at different doses of the drugs. “Regardless of type of medication, or combination of medications, we observed a beneficial effect of healthy eating,” Dehghan says.

In other words, the drugs work. But healthy eating helps a good deal too — and eating well while taking regular medication was associated with the best outcomes of all.

Dehghan says the new study is the most comprehensive research of its kind to date. That’s because of large size of the study population, but also the fact that it includes participants from 40 countries that represent not just developed and higher resource nations such as those in Europe and North America, but also middle-income countries in East Asia, South America, and the Middle East.

And because the study participants were asked to give detailed information about their medications, how faithfully they took them, and their lifestyle choices outside of what they ate, the researchers could adjust for potential factors that could also influence heart disease risk. For example, healthier eaters may experience fewer heart problems because they also tend to smoke less or exercise more or take their medications more diligently. But even after they controlled for these behaviors, the study showed a strong link between healthy diet and heart health.

That convinces Dehghan that it’s worthwhile for doctors to talk to their heart-disease patients about the importance of healthy food, even if they are keeping their blood pressure and cholesterol in check with prescription drugs. She says that healthy eating is not about one single nutrient or food group, but instead, about the big picture of providing the body a balanced and diverse source of nutrients. “People can eat healthy or unhealthy three times a day, so if you modify your diet it can have a big impact,” she says. Enough for even heart patients to avoid additional heart attacks, strokes or even early death from heart disease.