Twitter’s never-ending battle with spam accounts is now a challenge for new owner Elon Musk, who vowed in April to defeat the bot plague or “die trying!”

He later cited bots as the reason for not buying the social platform. Now that the billionaire has closed the deal, he faces the challenge of making good on his promise to clean up the fake profiles that plagued Twitter long before it expressed interest in acquiring it.

The issue carries high stakes. The number of bots matters because advertisers—Twitter’s main source of revenue—want to know roughly how many real people they’re reaching when they buy ads. It is also important to efforts to prevent malicious individuals from amassing an army of accounts to spread disinformation or harass political opponents.

“The bigger picture for me is how do we make Twitter a better place for everyone,” said bot-counting expert Emilio Ferraro, who worked over the summer to research Musk’s problem. He cited “the value of the platform as a social experience, as a collective place for civilized discourse and free conversation without interference from nefarious accounts,” as well as fraud, spam, pornography and harassment.

To find out just how bad the bots are, Musk hired Ferraro and other data scientists to investigate. At the time, he sought to prove that Twitter was misleading the public when it reported that less than 5 percent of its daily active users were fake or spam accounts. If Twitter had lied or withheld important information about the bot count, Musk could have argued that he had the right to cancel the $44 billion deal.

Ferraro, an associate professor of computer science and communications at the University of Southern California, said he was not interested in whether Musk would end up owning the platform.

Instead, he hoped “any findings would help improve the platform,” Ferraro told The Associated Press, speaking for the first time about his planned role as an expert witness for Musk.

The question now is what Musk will do with this information. Ferrari’s presentation — about 350 pages of analysis and supporting documents — is in a confidential court file, and he said he could not reveal his findings.

Former Twitter executives and its lawyers said Musk greatly exaggerated the problem because he had buyer’s remorse.

Other experts question Musk’s ability to make the improvements, which he says will rely on using algorithms to track down and remove fake accounts and introducing new measures to “authenticate” real people.

Earlier this month, Ferraro was preparing to travel to the East Coast to testify in Delaware, where Musk was defending against a lawsuit from Twitter that asked the court to force him to make the deal. But two weeks before the scheduled Oct. 17 trial, Musk changed his mind and said he would go ahead with the $44 billion acquisition. It closed on Thursday.

Most legal experts didn’t think Musk had much of a case. The court’s chief justice appeared to side with Twitter based on specific terms of the April purchase agreement.

But that doesn’t mean Musk didn’t have a point about bots, according to Ferrari and other researchers hired by Musk’s legal team.

CounterAction, an analytics firm that worked with Ferrara, said in a July 18 court filing that it concluded Twitter’s spam rate for monetized accounts — those with value to advertisers — was at least 10 percent. and could reach 14.2 percent. depending on how the rate is measured.

Trevor Davies, the firm’s founder and CEO, said the analysis was based on “fire hose” internal data that Twitter provided to Musk, but the company refused to provide additional data requested by Musk’s team.

“We expect that access to inaccessible data will reveal even greater levels of genuine spam,” Davis said in a prepared statement.

Musk has long been concerned about spam Twitter bots promoting cryptocurrency schemes, in part because as a famous user with more than 110 million followers, he sees a lot of them. Some scammers have created accounts impersonating Musk’s name and likeness to try to trick people into thinking he’s endorsing something.

Not all boots are bad. Twitter encourages the use of automated accounts that report the weather, earthquakes, or post humor or lines from literary classics. Twitter also allows anonymity, which protects freedom of speech and privacy – especially in authoritarian regions. But this practice can make rooting out malicious fake accounts more difficult.

Ferraro first came to Twitter’s attention after revelations that Russia used social media to interfere in the 2016 US presidential election, when he led a research team that estimated that 9 to 15 percent of active English-language Twitter accounts were bots.

In a blog post shortly afterward, Twitter complained that such outside research was “often inaccurate and methodologically flawed.” The company has repeatedly reported a figure of less than 5 percent in its quarterly filings with the Securities and Exchange Commission, though it also cautions that it could be higher.

Before Musk’s takeover, Twitter said it removed 1 million spam accounts every day. To calculate how many accounts are malicious spam, Twitter looks at thousands of randomly selected accounts using public and private data such as IP addresses, phone numbers, geolocation and how the account behaves when it’s active.

But in recent months, Musk and Twitter have argued over the methodology. Twitter uses a metric it calls mDAU to monetize daily engagement.

It’s “literally a metric they invented,” Ferraro said. “You can’t contrast and compare that metric with any other service.”

When Musk first began publicly raising questions about the number of bots after agreeing to buy the company, another firm, Israel’s Cyabra, said it had an answer.

“That elusive number you’re looking for … we’ve got it. That’s 13.7 percent,” the firm tweeted on May 17, tagging Musk’s Twitter address to get his attention.

Cyabra’s machine learning technology works by scanning large numbers of social media profiles to track behavioral patterns, trying to identify which ones behave like people. Such speculations may misfire — but the tweet attracted the attention of people close to Musk, if not the billionaire himself.

Cyabra CEO Dan Bramey said the company began working with the Musk camp by the end of May. Regardless of the true count, he said solving the problem will not be easy.

“Some of the boots are definitely vile,” Brummy said. “The trade-offs are between extremely high standards of registration and information security and extreme openness in the sense” that promotes freedom of speech and creativity.