Royal physicians were known to sniff noblemen’s excrements as a test for disease. That may sound disgusting, but modern science backs the idea that certain diseases cause the body to produce volatile compounds, which if detected properly could provide a powerful diagnostic method.

In the last 10 years, researchers have developed specific sniff tests for diagnosing tuberculosis, hypertension, cystic fibrosis, and even certain types of cancer. Here’s how it works: cystic fibrosis, for instance, causes patient’s bodies to function such that they produce nearly four times as much acetic acid (the base chemical in vinegar) as healthy people.

Now a group of global researchers led by Hossam Haick at the Israel Institute of Technology have taken the idea a step further. They’ve built a device—a kind of breathalyzer—that is compact and can diagnose up to 17 diseases from a single breath of a patient.

The breathalyzer has an array of specially created gold nanoparticles, which are sized at billionths of a meter, and mixed with similar-sized tubes of carbon. These together create a network that is able to interact differently with each of the nearly 100 volatile compounds that each person breaths out (apart from gases like nitrogen, oxygen, and carbon dioxide).

Haick’s team collected 2,800 breaths from more than 1,400 patients who were each suffering from at least one of 17 diseases (in three classes: cancer, inflammation, and neurological disorders). Each sample of the disease was then passed through the special breathalyzer, which then produced a dataset of the types of chemicals it could detect and in roughly what quantities.

The team then applied artificial intelligence to the dataset to search for patterns in the types of compounds detected and the concentrations they were detected at. As they report in the journal ACS Nano, the data from the breathalyzer could be used to accurately detect that a person is suffering from a unique disease nearly nine out of ten times.

Each of the diseases, ranging from kidney cancer to multiple sclerosis, had its own unique “breathprint.” Further analysis of the samples also revealed that, among the 100 or so volatile chemicals in a breath, variations in the levels of only 13 of them were key to disease detection.

The accuracy of the new breathalyzer is not yet at a level where it can be deployed in clinical settings. The success rate needs to be nearer to 99% rather than the current 86% for that. But as a proof-of-concept device, which is both compact and inexpensive, it’s a big step forward. And potentially, it could put a centuries-old idea into practical use.