Kids who got teased for sucking their thumbs or biting their nails may, after all, get the last laugh.

It turns out that repeatedly sticking grimy digits into your pie-hole as a youngster may help strengthen your immune system and prevent the development of allergies later in life, researchers report in the August issue of Pediatrics. The finding is certainly a score for the underdogs of the schoolyard, but it also lends more support to the “hygiene hypothesis.” This decades-old hypothesis generally suggests that exposure to germs and harmless microbes in childhood can help develop a healthy, tolerant immune system—that is, one not prone to autoimmune diseases and hypersensitive responses such as allergies.

“Although we do not suggest that children should be encouraged to take up these oral habits, the findings suggest that thumb-sucking and nail-biting reduce the risk for developing sensitization to common aeroallergens,” the study authors conclude.

The researchers, led by Stephanie Lynch of Dunedin School of Medicine in New Zealand, got the idea following reports that infants whose mothers licked their pacifiers clean were less likely to develop asthma and eczema. Sucking on thumbs and biting nails might have the same effect they reasoned.

Lynch and colleagues examined data from the Dunedin Multidisciplinary Health and Development Study, which had been tracking 1,037 kids born in Dunedin, New Zealand, between 1972 and 1973. In that study, parents were surveyed on their kids’ thumb-sucking and nail-biting ways when the kids were 5, 7, 9, and 11 years old. Most of the kids were also given skin-prick allergy tests at ages 13 and 32. Those tests looked for responses to common allergens, such as dust mites, grass pollen, cats, dogs, horses, wool, and mundane molds. The researchers also collected information on other factors that may influence allergy development, including breastfeeding, cat and dog ownership, parental smoking and allergies, crowded living conditions, and socioeconomic status.

According to the parent survey responses, 31 percent of the kids were “frequent” finger munchers—either nail-biters, thumb-suckers, or both—at some point between the ages of 5 and 11.

At 13 years old, 724 kids took the skin prick test, and 45 percent of them had at least one allergy. But, when the kids were sorted out, the ones with oral habits fared better. Of the kids that neither sucked their thumbs nor bit their nails, 49 percent had allergies. Of the kids that had one of those oral habits, 41 percent had allergies. And of the kids who did both, 31 percent had allergies.

At 32 years old, 946 of the kids—now adults—took the skin test again. The results were similar, except at this age the participants that had both oral habits in childhood fared about the same as those that had just one. Still, the results held up: shoving germy fingers in your mouth as a kid seemed to lessen the chances of allergies later in life by about 30 to 40 percent. And the results also held up after researchers controlled for the other allergy-altering environmental and genetic factors.

However, the researchers also looked at whether finger munching generally lessened the incidence of asthma and hay fever and didn’t find a link. They'll have to do more research with other groups of kids to validate the results and try to understand how the unhygienic habit may be affecting some allergies and not others.

Lastly, the authors note that finger biting and thumb-sucking have been linked to problems other than schoolyard bullying, such as misalignment of teeth and finger infections. But if the study is correct, these “bad habits” may not be all bad.

Pediatrics, 2016. DOI: 10.1542/peds.2016-0443 (About DOIs).