Bill Gates wasn’t sniffing “poop” for nothing.

As the billionaire philanthropist explains in a recent Gates Notes blog post, he recently spent time smelling an artificial scent of feces in Geneva, Switzerland as part of a plan to help people in poor areas have an easier time using the bathroom.

In India and other poor countries, sanitation continues to be a problem – some 800,000 children under 5 die annually from diarrhea or other sanitation-related ailments.

Although pit latrines give people a place to defecate, many smell so bad that people choose to go out in the open, which creates public-health threats by allowing bacteria and disease to spread.

Gates’ solution to this problem: Partner with Firmenich, a 120-year-old perfume company, to develop an “anti-poop” scent that masks bad odors in the same way noise-cancelling headphones use wave patterns to block noise.

Essentially, the perfume acts as a high-tech Febreze, blocking the receptors in your nose that cause you perceive bad odors. The hope is that the spraying the product in latrines will encourage people to use them, since the smell will no longer seem so offensive.

Developing this anti-poop scent was no small feat.

“Toilet odors are actually quite complex,” Gates writes. “They consist of more than 200 different chemical compounds arising from feces and urine that change over time and vary depending on the health and diet.”

Firmenich tested each of these compounds in its lab to figure out which were the foulest. They arrived at four: indole, p-cresol, dimethyl trisulfide, and butyric acid. When he stuck his nose into a glass tube in Geneva, these were the ones that hit his olfactory receptors.

“It smelled as bad as the worst toilets I’ve ever visited,” he says.

By knowing which scents were the worst, Firmenich could reverse-engineer its counterpart: a smell that, as Gates describes, masks “stinky sewage, sweat, and ripe cheese” with “a pleasant floral scent.”

Firmenich is launching pilot programs in India and Africa to test out its new creation. The company hopes to learn how well the new scent encourages people to use latrines and which forms of the scent – such as powders or sprays – are best at keeping nasty smells at bay.

“I continue to be amazed by the innovation that’s underway in the field of sanitation,” Gates writes.

Toilets used to be a taboo subject, he explains. Now they’re subjects of mainstream research that stands to improve the lives of billions around the world.