When I lived in L.A., I reported on a school near Long Beach in which nearly a fifth of the students had asthma. One culprit seemed to be the school’s unfortunate geography: About 500 trucks passed by its grounds every hour, and according to a study released at the time, at least 9 percent of childhood-asthma cases in the area were attributable to road traffic. The air near the school, which sometimes smelled rotten or rubbery, contained nearly twice the normal level of elemental carbon, a marker of diesel particles.

Asthma is just one of the health problems linked to air pollution exposure. Sniffing exhaust all day also contributes to everything from stroke to premature death.

Conversely, spending time in nature is correlated with better mental health, attention, and mood in both children and adults. A new study out Monday in the Proceedings of the National Academy of Sciences suggests that green spaces can actually boost cognitive outcomes in children—in part by protecting their brains from air pollutants.

For the large study involving 2,623 schoolchildren in Barcelona, researchers first assessed the amount of greenery around the children’s homes, along their commutes to school, and surrounding the schools themselves. They then measured the children’s working memories and attention spans using a series of word and number tests.