After trouble in India, WhatsApp is in hot water in Brazil due to the spread of fake news ahead of presidential elections and has banned hundreds of thousands of accounts in response.

“We have cutting-edge technology to detect spam that identifies accounts with abnormal behaviour so that they can’t be used to spread spam or misinformation,” a WhatsApp reresentative told Bloomberg in an emailed statement.

The representative added: “We are also taking immediate legal measures to prevent companies from sending mass messages via WhatsApp and have already banned accounts associated with those companies.”

Local media reports said presidential candidate Jair Bolsonaro’s supporters paid marketing companies up to $3.26 million each to create a social media campaign against rival Fernando Haddad.

WhatsApp said it is “taking immediate legal action to stop companies from sending bulk messages” while a Brazilian court stated it will investigate the matter. The federal police has also begun a probe into allegations of spam messages.

The users blocked from WhatsApp included Bolsonaro’s son Flavio and an account linked to former Brazilian president Dilma Rousseff.

WhatsApp has more than 120 million users in Brazil and the country is one of its biggest markets.

It is no stranger to controversy in the country: in 2015 and 2016 the app was temporarily banned in relation to not handing over data linked to a criminal investigation.

Meanwhile in India, where the messaging service has 200 million users, around a dozen people were reportedly killed between May and July by angry mobs incited to violence by fake news spread on the app.

In trying to deal with the problem WhatsApp said it is limiting the number of groups a message can be forwarded to worldwide, with further restrictions in India, where it removed a quick forward button.