A man facing murder charges in a shooting at a Minnesota medical clinic purchased the gun with a permit from a local police department despite having a restraining order for threatening the clinic in the past, AP reports

67-year-old Gregory Ulrich was charged in an attack on Allina Health clinic in Buffalo, Minnesota this month that left medical assistant Lindsay Overbay dead and four other people wounded. In October 2018, Ulrich was banned from the clinic property for threatening to attack the facility.

Ulrich was also hit with a restraining order that prohibited him from owning guns and contacting doctors at the clinic. Additionally, he had been arrested for his violating the restraining order in the past. But an unidentified law enforcement source told the Star Tribune that the Buffalo police department granted Ulrich to buy the handgun that was eventually used in the attack.

Ulrich’s 2019 harassment case includes a notation claiming that he had applied to purchase a gun and that the approval was pending. The source said he “highly recommended” against allowing Ulrich to have any weapons. When a psychological evaluation was ordered, the case was dismissed because Ulrich was found “mentally incompetent to proceed.”

Ulrich was charged on Thursday. His bail was set at $10 million or $5 million with conditions. Buffalo Police Chief Pat Budke declined to answer questions about the case but released a statement claiming that the city can’t release gun permit records.