The health benefits of exercise have been touted to no end, but their purported benefits have mostly been with regards to preventing people from developing heart disease or diabetes. But for people who already have these conditions, exercise can still benefit their health, and in some instances, it can work better than prescription medications at preventing death.

In a study of 305 randomized controlled trials, researchers at the London School of Economics, Harvard Pilgrim Health Care Institute, and Stanford University School of Medicine looked at data to compare the effects of exercise to prescription drugs among 339,274 patients who were undergoing secondary prevention for coronary heart disease, stroke, heart failure, and prediabetes, BBC reports.

Whether they exercised or took prescription drugs, there was no significant difference in preventing death among coronary heart disease patients and prediabetes patients. But when it came to stroke patients, the benefits of exercise outweighed prescription drugs. Conversely, heart failure patients were better off sticking to their prescriptions, particularly diuretics, than to exercise, the researchers found.

“Medicines are an extremely important part of the treatment for so many heart conditions and people on prescribed drugs should keep taking their vital meds,” Amy Thompson, senior cardiac nurse at the British Heart Foundation, told BBC.

The researchers emphasized the importance of prescription medications but said that patients who added exercise could further reduce their risk of more severe illness. According to the Centers for Disease Control and Prevention (CDC), less than 48 percent of U.S. adults meet the recommended guidelines for physical activity.

“By taking important steps, such as regular exercise, eating a balanced diet, and stopping smoking, people can significantly reduce their risk of stroke,” Dr. Peter Coleman, of the Stroke Association, told BBC. “Moderate physical activity, for example, can reduce the risk of stroke by up to 27 percent.”

Source: Naci H, Ioannidis J. Comparative effectiveness of exercise and drug interventions on mortality outcomes: metaepidemiological study. BMJ. 2013.