ACCOUNTING scandals are nothing new in Brazil. Its former president, Dilma Rousseff, was impeached in August for cooking her government’s books. The bosses of its biggest building firms have landed behind bars for padding contracts with Petrobras, the state-run oil company. At least, governance gurus joke, all the imbroglios—and a three-year-old law against bribery—have prompted companies to replace what people used to call corruption departments with compliance offices. How ironic, then, that Brazil’s latest affair involves a firm that is meant to ensure that firms stay on the straight and narrow.

On December 5th it emerged that America’s Public Company Accounting Oversight Board (PCAOB) fined the Brazilian arm of Deloitte, the biggest of the “Big Four” accounting networks, $8m, for what Claudius Modesti, the watchdog’s director of enforcement, called “the most serious misconduct we’ve uncovered”. Deloitte is the first of the Big Four to be accused of failing to co-operate with a probe by the PCAOB, created by the Sarbanes-Oxley act of 2002, itself a response to a massive accounting scandal at Enron, an energy giant. The firm will also have to pay 5.4m reais ($1.6m) to Brazil’s securities regulator.

The bulk of the problems centre on Deloitte’s auditing of Gol, a troubled Brazilian low-cost airline with shares listed in New York. It was in 2012 that the PCAOB examined the firm’s audit papers during a routine review. Its inspectors found that a year before, Deloitte’s senior auditors had signed off on the carrier’s books despite knowing that its staff were still reviewing these for mis-statements, in particular related to reserves set aside to cover aircraft-maintenance costs. A subsequent probe unearthed systematic attempts by managers and partners to doctor paperwork, conceal evidence and withhold information from inspectors. Similar shenanigans apparently marred Deloitte’s audits of Oi, a Brazilian telecoms firm which filed for bankruptcy protection in June.

Relative to the scale of fines that regulators have been doling out to banks in recent years, Deloitte’s bill looks tiny. But it is a record for the PCAOB. A dozen (now former) partners and auditors have been banned from working at any of the accounting firms the PCAOB oversees, all but one of them for life. As part of its settlement with the agency, Deloitte Brazil also faces the humiliating presence of an independent monitor until at least mid-2017.

Critics of auditors will cite the Deloitte case as further evidence that the world is suffering from an outbreak of accounting fraud. The PCAOB has just fined Deloitte Mexico $750,000 for tampering with documents in an audit there. In August PwC settled a case in which a plaintiff was seeking $5.5bn after Colonial BancGroup, an American lender it audited, went bust. Last year EY, another Big Four firm, failed to flag problems at Toshiba that forced the Japanese firm to restate its accounts by $1.9bn.

Still, the overall trend around the world has been for accounting to get cleaner. In America one good measure of this is the size of the biggest accounting restatement in a given year. It has plummeted over the past decade, from over $6bn to under $1bn. The scale of all restatements was only $2.7bn, or just 0.3% of all corporate profits, in 2015. Standards outside America have improved, too, partly because Europe and many emerging economies, including those of Latin America, have adopted common international accounting standards. Deloitte’s Brazilian fiasco is depressing, but at least skulduggery is being uncovered and punished.