The armed assault on a Washington, D.C., family restaurant last Sunday was perplexing for a variety of reasons. Why did Edgar Welch take the harebrained “Pizzagate” Internet conspiracy theory so seriously he felt compelled to bring three guns with him on a drive from North Carolina to Comet Ping Pong? Given Welch’s criminal record, which includes two drug possession charges, how did he manage to get those weapons? Doesn’t federal law prohibit people with documented history of possessing or using illegal substances from buying guns?

The answer to what motivated Welch is still being sorted out. On Monday, D.C. police said that Welch told them that he had driven to the pizzeria to “self-investigate” bogus sex abuse claims made against the establishment during and immediately after the heated presidential election.

Once in the restaurant he pointed a rifle at an employee and fired at least one shot into the floor before surrendering.

It’s also not yet clear where, or how, Welch obtained his arsenal — an AR-15 rifle, a .38-caliber revolver, and a shotgun. But it appears that despite his rap sheet, he is not what the FBI or the Bureau of Alcohol, Tobacco, Firearms and Explosives deem a “prohibited purchaser,” someone flagged in the federal background check system as unfit to receive a firearm in a gun purchase or transfer.

John Sifford, a captain in the sheriff’s office in Rowan County, where Welch lives, said the gunman’s misdemeanor charges would not have impeded the department from issuing him a concealed weapons license or a permit to purchase a pistol. But there is no evidence that Welch applied for, or received these permissions, Sifford said.

It appears that Welch may have not obtained legal permission to buy or carry the .38-caliber revolver found in his possession in the pizza parlor.

Broadly speaking, convicted felons are not allowed to own or buy guns in the U.S. A federal background check form asks prospective buyers if they are “an unlawful user” of drugs or “addicted to a controlled substance” — a vague classification that can include misdemeanor drug offenses. In the last two decades, the FBI has blocked hundreds of thousands of people with records of drug possession or use from buying firearms.

It can sometimes take more than three days to sort out the specifics of a would-be buyers drug record. If that happens, sales automatically go through — sometimes with calamitous results.

After Dylann Roof killed nine churchgoers in Charleston, South Carolina, federal officials found that he should have been prohibited from buying the gun he used in that crime: Three months earlier, Roof had confessed to misdemeanor illegal possession of drugs, specifically suboxone, a prescription pharmaceutical used to manage opioid addictions. Due to a paperwork error, the FBI was not able to determine that Roof’s charge was indeed sufficient to block his gun purchase within three days, at which point he got the weapon anyway in what’s called a default proceed sale.

Welch had also been convicted of drug crimes. In 2007, he pleaded guilty to two misdemeanor drug possession charges. But the “unlawful user” prohibition has an expiration date. A conviction, positive drug test, or confession only prohibits individuals from buying guns if it occurred in the past year. That’s according to the FBI’s detailed guidelines about just what designates someone as an “unlawful user” of illegal drugs, which indicates that Welch was probably not covered by the prohibition.

So as long as Welch obtained his guns after 2008, there is likely no legal reason why the sales should have been blocked. Stephen Fischer, an FBI spokesman, declined to directly address whether Welch had passed a background check or not, due privacy restrictions.

Welch had other run ins with the law. Also in 2007, he pleaded guilty to driving after consuming alcohol and with an open container. (This October, he struck and severely injured a teenager with his vehicle, though the incident did not result in criminal charges.) Alcohol-related misdemeanors don’t stand in the way of passing a federal background check, and only a small handful of states like neighboring South Carolina impose their own restrictions on people with histories of drunken behavior. However, states like Virginia or Florida suspend concealed carry licenses after DUIs.

The system designed to keep guns out of the hands of dangerous people is riddled with complexities like these. State laws complicate things further: There are varying rules regarding who can carry guns in public, and some states employ different standards for allowing or denying gun purchases.

In Welch’s native North Carolina, gun laws are relatively loose. The state allows individuals to buy rifles and shotguns without undergoing background checks, but citizens must obtain a permit to purchase a handgun or carry a concealed weapon. These permits are issued by the local sheriff’s office.

The Trace has asked the Rowan County Sheriff’s Department if there is any other way that Welch would have been able to legally purchase the pistol without receiving a permit in advance. We will update with the department’s response.