The Obama administration on Tuesday released previously classified documents showing that National Security Agency employees routinely accessed a phone-records database without legal approval and misled a secret court about their actions.

The documents made public by Director of National Intelligence James Clapper show that NSA workers searched a database that held the phone records of Americans not connected to terror investigations. A judge on the top-secret Foreign Intelligence Surveillance Court ultimately ordered the NSA to make major changes to the program in 2009.

U.S. District Judge Reggie Walton wrote in the just-released opinion that he “lost confidence” in federal officials’ ability to properly oversee the program and was “deeply troubled by the incidents.”

Walton says that he even considered shutting down the program.

The data in question includes phone numbers dialed by Americans and the location of their calls but not the actual content of the conversations.