A three-stage investigation of keywords on Twitter turned up illegal sales of opioids—potentially leading to an illegal operation.

The investigatory method, developed by medical doctors and computer engineers at the University of California–San Diego, was too late to catch most of the sites in the act. But the analysis could be used to target illegal drug trafficking and other criminality of the future, online and in real time, they write in the American Journal of Public Health this month

“As evidenced by our findings, extremely questionable vendors are advertising highly addictive controlled substances and selling them directly to consumers via Twitter without the necessary oversight of a clinician, regulatory agency, or state public health or law enforcement agency,” they write.

The team assessed approximately 620,000 tweets over a five-month period from June to November 2015, which involved the keywords “codeine,” “Percocet,” “fentanyl,” “Vicodin,” “Oxycontin,” “oxycodone” and “hydrocodone.”

The three-part analysis was made possible through artificial intelligence. The first step involved collecting the tweets, through the Amazon Web Services EC2 t2.micro virtual instances preconfigured with RStudio, they explain. The second stage involved using an unsupervised machine-learning technique called topic modeling, through which the computers identified the tweets that specifically made mention of marketing and sales of the substances. The third and final phase was forensic examination of the tweets that remained, looking for viable links and further directions pertaining to sales.

The total number of tweets selling the drugs: 1,778, they report. Most (1,608) had embedded hyperlinks. But only a total of 46 remained active at the time of the analysis, which was completed in 2016—at least months after they had been collected.

“The delay probably resulted in a higher percentage of signal data with ‘dead’ hyperlinks, suggesting that our methodology is most effective when used with real-time data as opposed to retrospective data,” they explain.

Through the overall collection, however, they determined that the most active marketers were sites linked through Pakistan—one of which called itself the “World Most Trusted Health Care Online Mall,” the paper explains.

“Thus, it appears that Twitter represents a viable modality for criminal actors to engage in the illegal marketing and sale of prescription controlled substances online, despite laws in the United States and other countries specifically prohibiting these practices,” they write.

“Our study’s methodology can also be adapted for other approaches aimed at detecting small volumes of Twitter discussions that may be associated with criminal health-related activities,” they add.

Online marketing of prescription opioids was made illegal by the Ryan Haight Online Pharmacy Consumer Protection Act passed in 2008, named after a teenager in California who died in 2001 after purchasing Vicodin through a website.

Tim K. Mackey, one of the authors, an anesthesiologist at UC–San Diego, said in a school statement the investigatory technique could be used immediately in combating online opioid sales, or finding other criminality.

“This technology could help improve enforcement of the Ryan Haight Act,” said Mackey. “In addition, social media providers can use it to find or prohibit content that is illegal or violates laws to ensure consumers have a safer experience online.”

The opioid epidemic continues unabated in the U.S.—and President Donald Trump has said over several weeks that he would declare a public health emergency over it.