A federal judge has ordered the government to stop destroying National Security Agency surveillance records that could be used to challenge the legality of its spying programs in court.

U.S. District Court Judge Jeffrey White’s ruling came at the request of the Electronic Frontier Foundation, which is in the midst of a case challenging NSA’s ability to surveil foreign citizen’s U.S.-based email and social media accounts.

According to the EFF, the signals intelligence agency and the Department of Justice were knowingly destroying key evidence in the case by purposefully misinterpreting earlier preservation orders by multiple courts, multiple times.