An undated photo shows Omar Mateen, who Orlando, Florida, police say killed at least 49 people at a gay nightclub in Orlando, Florida, June 12, 2016. Omar Mateen via Myspace/Handout via Reuters

Three years before Omar Mateen walked into a Florida nightclub wielding an assault rifle and a handgun, he was questioned twice by the FBI about links to terrorist organizations overseas. But despite their direct questioning — and despite a high-tech FBI anti-terrorism database that has cost taxpayers billions of dollars to build — the gunman slipped through the FBI’s reach.

On Saturday night, using weapons he bought within the past two weeks, Mateen gunned down 49 people and injured 53 more in an Orlando nightclub. The massacre is America’s worst mass shooting in history.

As investigators piece together what motivated Mateen to unleash the bloody slaughter, another important question will linger for both the FBI and lawmakers: How effective are the country’s surveillance and database systems if a man who was at one time under terror suspicion by the federal government can freely buy an assault rifle just two years after being investigated by the FBI?

Because Mateen's case file was closed by agents in 2014, he was removed from certain databases and thus eligible to purchase a gun.

Specifically, gun databases don’t cross-reference with databases that show who gets questioned by the FBI, according to Peter D. Yachmetz, a retired FBI agent who worked in counterterrorism in the Orlando office. “It would take a tremendous amount of resources to get all the databases to cross-reference,” Yachmetz says. “All of those databases don’t talk to each other. When you go to apply for a gun, they put you in to see if you have a criminal record. That database does not show if you were spoken to by the FBI, CIA, ATF, etc.”

This question, along with hot-button issues like gun control and Islamic extremism, will continue to dominate the conversations around the 2016 presidential race. "How many more of these mass tragedies do we have to live through?" Democratic nominee Hillary Clinton asked on NBC's "Today Show."

Since the terrorist attacks of 9/11, the FBI has quietly expanded its high-tech surveillance network in the name of anti-terrorism and increased national security. Recently, the FBI has pushed for legislation that would require so-called backdoors into technology products.

But perhaps the FBI's most ambitious anti-terror technology to date is its Next Generation Identification (NGI) unit, a $1.2 billion initiative that collects vast amounts of biometric information on criminals and suspected terrorists. The NGI maintains the largest biometric database in the world. As International Business Times reported in April 2016, the searchable “face catalog” of mug shots and U.S. visa photos now includes 548 million pictures.

Right now, it’s unclear if NGI had maintained images or other biometric information on Mateen, the Orlando shooter. An NGI official referred inquiries about Mateen to the national FBI office, which did not return comment by press time.

What is clear, however, is that as the FBI has advocated for an expansion of surveillance and databases, they’ve been met with staunch criticism by civil liberties advocates and others who say this sort of technology will simply lead to more mass surveillance — while not actually catching terrorists and other criminals.

“What we’re seeing is how counterterrorism and counterinsurgency tactics are being codified into everyday policing,” said Hamid Khan, the founder of a grassroots group called Stop LAPD Spying, in IBT’s April story. “In essence, we’re all suspects.”

While predictive policing and biometric databases recall science fiction films like "Minority Report," their effectiveness is often called into question after events like the San Bernardino shooting and the Orlando terror attack, where shooters seemingly slip through the cracks. Mateen, who allegedly called 911 operators on the night of his attack to proclaim allegiance to the Islamic State group, was questioned by FBI agents on two separate occasions.

The first time the FBI questioned Mateen, in 2013, it was because he’d commented to co-workers about having friends in al Qaeda and Hezbollah. In 2014, the FBI questioned Mateen “over possible contacts with Moner Mohammad Abu-Salha, a Florida man who traveled to Syria and carried out a suicide truck-bombing attack,” according to The Wall Street Journal.

Yachmetz says that in his capacity as an Orlando FBI counterterrorism agent, he’d be tasked with questioning dozens of potential suspects in any given month. Many suspects are questioned, and if an agent does not feel that individual warrants a full investigation, the case file is closed, and the person is removed from watchlists.

Asked whether Sunday’s Orlando massacre could potentially lead to a broadening of who gets placed on terror watch lists and databases, Yachmetz says it’s possible.

The FBI, he said, could “review what guidelines are in effect to possibly make the availability of the databases a little less stringent” than they currently are.