When the government announced this summer that more than 4 million federal employees had their personal information stolen—likely by Chinese hackers—lawmakers and victims were outraged. Officials pointed fingers, the FBI threatened retaliation, and the government handed out meager compensation: a free year of credit monitoring for the affected workers.

Things only got worse from there. It soon became clear that the Office of Personnel Management had been breached more than once, and that the agency’s original estimate of the damage could be low. Government workers who hadn’t heard from the government about the first breach began to wonder if their data was caught up in a potentially much bigger hack. It took four weeks, but the answer finally came, and the difference in scale was astounding.

More than 22 million people—government employees, retirees, and their relatives—were affected by the data breaches at OPM. Of those people, the agency initially said, about 1 million also had their fingerprints revealed. Months later, it returned with another update: The number of fingerprints lost to hackers was in fact more than five times higher than initially estimated.

Why did this agency, which functions as the federal government’s human-resources department, have so much trouble protecting its data? For one, it didn’t know how much it had to begin with.

According to its inspector general, at the time of the breaches, OPM did not have a complete inventory of the servers, databases, and network devices that it owns, maintains, and operates. Not having the inventory “drastically diminishe[d] the effectiveness of its security controls,” wrote Michael Esser, the agency’s assistant inspector general for audits, in an oversight report published this month.

“Failure to maintain an accurate IT inventory undermines all attempts at securing OPM’s information systems,” the report read.

OPM only completed an inventory of its databases within the last few months, said Sam Schumach, a spokesperson for the agency. As far back as 2009, the inspector’s office began warning that the agency was having trouble keeping track of its information systems. The following year, auditors noted that OPM’s “passive approach” to maintaining its inventory was putting its sensitive data at risk.

The agency is still cleaning up from the breaches it announced this summer. After hiring a contractor to contact the millions of individuals who had not yet heard from the government, the agency finally began sending out notification letters. As of last week, 14 million letters have been sent, Schumach said. OPM hopes to send out the last of the letters by mid-December.

Dealing with the fallout of a data breach is expensive. Just notifying the individuals affected by the hack set the government back $133 million. Recognizing that cyber attacks that target government data will only ramp up in the future, OPM has already budgeted an additional $500 million for data breaches over the next five years.

OPM is slated to receive updated cybersecurity systems for its networks in the “near future,” a spokesperson for the Department of Homeland security said. The new system, which has the capability to block incoming attacks, will replace a system that could only monitor networks for intrusions.

But even those tools would be useless without a basic understanding of the data the agency is entrusted with, and the servers that hold that data.

The high-profile data breaches have kept OPM in the news, but it’s far from the only government agency that has fallen short of basic IT standards.

A recent report compiled by the House Oversight Committee graded federal agencies on their implementation of a key federal IT law. The majority of agencies—including OPM—received a D grade. Three agencies received an F: the Department of Education, the Department of Energy, and NASA. No agency received an A.