Japanese scientists have come up with an ingenious way to keep flies off cattle — turn them into zebras.

A team of researchers painted Japanese black cows with black-and-white stripes as part of the experiment based on the observation that the stripes on zebras seem to confuse flies and keeps them at bay, according to a report Tuesday in Real Clear Science.

The scientists conducted two studies in 2017 and last year, painting three cows each time. It took five minutes to cover each cow with non-toxic paint and they then compared the number of flies buzzing around the zebra-cows with unpainted bovines for three days, according to their findings , published in the science journal PLOS ONE.

“We found that painting zebra-like stripes on domesticated cows can decrease the incidence of biting flies landing on individuals by 50%,” the researchers reported. “We also found that the reduced landings of biting flies coincide with a reduction in defensive behaviors in cows.”

In addition to keeping the cows healthier and happier, the cow-painting approach is environmentally friendly, negating the need to spray pesticides to get rid of the flies.

It’s no small finding for ranchers — flies cause roughly $2.2 billion in losses for the U.S. cattle industry every year because bug bites make cows eat less, sleep less and become more stressed, according to Real Clear Science.