First the bad news: There is no 100 percent effective way to avoid a heart attack. But here’s the good news: You can help prevent a heart attack by exercising to keep your weight down and your cardiovascular system strong. Plus, new findings published in Mayo Clinical Proceedings show that if you experience a heart attack, you’re more likely to survive if you stay in shape, Time reports.

For the study, researchers at the Johns Hopkins Ciccarone Center for the Prevention of Heart Disease studied the health records of more than 2,000 men and women who took a treadmill test to evaluate their fitness. Scientists found that patients with the highest fitness scores were 40 percent less likely to die after their first heart attack than those with lower scores.

What’s more, researchers said about a third of patients in the study with the lowest fitness scores died within a year of having their first heart attack.

“The thinking here is that if you are more fit at baseline, you are more willing to withstand lots of insults and have a good outcome if you do have a heart attack,” said Michael Blaha, MD, MPH, the cardiologist in charge of the study.

Scientists said the findings are important because they help prove that making changes to address your risk factors for heart disease is effective both before—and after—a serious heart event. Plus, staying fit can make you more likely to live to tell the tale.

For more tips on how to help prevent a heart attack, click here.