A jail staffer’s clerical error enabled Dylann Roof to obtain the gun used in the Charleston, South Carolina, church shooting last month, when he allegedly murdered nine people. Lexington County Sheriff Jay Koon told the Associated Press on Monday that a county jail employee entered the wrong information into a database of arrests made in the state.

Roof was arrested Feb. 28 on charges of drug possession. The records initially were incorrect about which police agency took Roof into custody, but the records were corrected two days after his arrest. While Lexington County’s jail records were updated, the revised information was not sent to the South Carolina Law Enforcement Division. That agency maintains the records used by the FBI to perform criminal background checks for gun purchases and other purposes.

When Roof attempted to purchase a gun in April, an FBI examiner called Lexington County deputies, who said the arrest happened in Columbia, South Carolina, according to the AP. But the waiting period for the gun had expired and the gun was sold before the report was found.