Before Omar Mateen took the lives of 49 people in Orlando on June 12, he was a licensed security guard with British-based G4S, a company that rode the post-9/11 wave of counterterrorism budgets. The Florida shooting has focused critical attention on the company, which has been the subject of a number of embarrassing reports. But G4S is just a symptom of a larger problem: counterterrorism spending in the United States is generally poorly managed and monitored.

In Chasing Ghosts: The Policing of Terrorism, published in November, John Mueller and Mark Stewart argue that public anxiety about terrorism has resulted in the rapid expansion of counterterrorist programs and investments, very little of which justifies its cost. By their numbers, the United States spends roughly $115 billion per year on domestic homeland security, much of it on a variety of agencies, programs, technologies, and other efforts to disrupt or deter domestic terrorism. They write that the counterterrorism field includes at least 1,072 governmental organizations and agencies, plus some 2,000 private companies funded by U.S. tax dollars. That means lots of money for companies like G4S, which hired Mateen back in 2007.

Mateen worked for G4S Secure Solutions, known as Wackenhut Security before it became G4S’s U.S. subsidiary. Based in Jupiter, Florida, G4S Secure Solutions currently holds at least one contract with DHS.

Mateen was working for G4S as a security guard at a courthouse in 2013 when his co-workers became alarmed by “statements that were inflammatory and contradictory,” FBI Director James Comey told reporters on Monday. “First, he claimed family connections to al Qaeda. He also said that he was a member of Hezbollah, which is a Shia terrorist organization and a bitter enemy of the Islamic State, or ISIL. He said that he hoped that law enforcement would raid his apartment and assault his wife and child so he could martyr himself. When this was reported to us, the FBI’s Miami office opened a preliminary investigation.”

Over the next ten months, the FBI examined Mateen to determine if he was, in fact, a terrorist, “something we do in hundreds and hundreds of cases all across the country,” said Comey. That involved introducing confidential sources to Mateen, recording conversations with him, following him, reviewing transactional records from his communications, and searching government holdings for any possible connections. During the interviews, Comey said, Mateen admitted that he made the statements but said he was just trying to scare co-workers who had bullied him.

In July 2014, the FBI became concerned that Mateen was connected to Moner Mohammad Abusalha, a suicide bomber affiliated with the Nusra Front, a rival to ISIS in Syria. Abusalha had grown up in nearby Vero Beach, Florida. “Our investigation turned up no ties” of any consequence between the two, Comey said Monday.

Before you blame the FBI for failing to take Mateen seriously enough, consider that the government follows up on 5,000 tips (or leads) a day according Mueller and Mark Stewart.

A bit more disturbing is that G4S continued to employ Mateen after the first incident, enabling him to keep his security guard license. He also had a license to carry a handgun, like the Glock pistol he took to the shooting at the Orlando club. Florida doesn’t require any special permit or license to purchase an assault rifle of the type Mateen used to kill his victims.

The stock market, at any rate, has punished G4S, sending its shares down significantly on Monday.

The massacre at the Pulse nightclub suggests that the $1 trillion U.S. tax dollars that have gone to domestic counterterrorism since 9/11 are at least somewhat poorly accounted for. That conclusion is backed up by a 2010 National Academies of Science report which, noted DHS did not have any “risk analysis capabilities and methods” to make sure that the money it was giving to companies like G4S was going to the right place.

“The report, which essentially suggested that the DHS had spent hundreds of billions of dollars without knowing what it was doing, generated no coverage in the media whatsoever,” Mueller and Stewart write.

It’s hard to think of a worse place for U.S. counterrorism dollars than the pocket of Omar Mateen.