Exercising with a friend might be better for your health than exercising all alone, reducing stress and improving quality of life. New research suggests that group exercise, such as in a fitness class setting, may reduce stress by about a quarter but people who go solo may not see any change at all.

The study, published in the Journal of the American Osteopathic Association, focused specifically on almost 70 medical students at the University of New England College of Osteopathic Medicine, following those who exercised in half-hour group fitness classes; those who worked out alone or worked out with one or two partners; and those who did not exercise at all. At the end of the 12-week study period, the group that took fitness classes had lower self-reported stress levels and improved physical, mental and emotional quality of life, according to the study, while the people who worked out alone or with partners had just improved mental quality of life. The control group that was going without exercise saw no difference.

“Attending weekly group fitness classes could be a solution to improving the emotional well-being and stress level of medical students,” the authors wrote.

While the study says the medical students were chosen as subjects because of the stress their schooling typically puts on those enrolled, the findings could potentially apply to other people as well. Other studies have already shown that physical activity can have a positive effect on mental health.

“Medical school often produces intense psychological distress for medical students,” the study notes. “This distress is manifested as depression, anxiety, burnout, increased alcohol use, fatigue, and low quality of life. … These findings have important implications for both personal well-being as well as empathy, interpersonal relationships, and attitude toward the medical profession.”

It’s possible that the students’ own dispositions had something to do with their changes, however — the subjects chose which of the exercise groups they would fall into, so their own inclinations for physical activity may have played a role in their improvements.

Still, during the study period “those who exercise individually put in more effort but experienced no significant changes in their stress level and a limited improvement to quality of life,” the American Osteopathic Association said in a statement about the research.

The individual exercisers typically worked out for double the time of the fitness class attendees.

If the results are correct, in addition to showing medical students how to improve their own mental and emotional health, the researchers say, it could guide them when they are counseling patients down the road: “This research is not only relevant to students during their medical education, but also to their lives as future physicians,” according to the study.

The difference that these students saw might have something to do with the social nature of people.

“The communal benefits of coming together with friends and colleagues, and doing something difficult, while encouraging one another, pays dividends beyond exercising alone,” lead researcher Dayna Yorks said in the association statement. “The findings support the concept of a mental, physical and emotional approach to health that is necessary for student doctors and physicians.”