A former district attorney in Pennsylvania’s Montgomery County claimed in a recent email that his office agreed more than a decade ago that a key deposition given by Bill Cosby could not be used in any criminal case, reported CNN, which said it obtained a copy of the message. The email could reportedly call into the question the viability of a criminal case against the 78-year-old actor and comedian, who faces three felony charges of sexual assault in that county.

Criminal charges against Cosby, centered on an alleged incident in 2004, were filed in December. They marked the first time he was charged after more than 50 women came forward claiming he either assaulted or drugged them. CNN reported the email was sent in 2015 by former District Attorney Bruce Castor to successor Risa Vetri Ferman and that the message describes an apparent oral agreement between the prosecutor and Cosby’s attorneys that was reached to get Cosby to testify in a 2005 civil sexual-assault case.

Castor reportedly wrote in the email that the agreement made 10 years before was aimed at giving Cosby’s accuser, Andrea Constand, the best chance at winning the civil suit by removing the ability to invoke his Fifth Amendment right under the U.S. Constitution. The allegations by Constand are at the center of the current criminal case. The email from Castor was sent three months before the filing of criminal charges against Cosby in Montgomery County. 

The deposition given by Cosby is potentially damaging — in it, he admits he had sexual relationships with at least five women outside his marriage, gave prescription sedatives to women and attempted to conceal affairs from his wife — and was cited by prosecutors as a reason for reopening the case.

In the email to Ferman, Castor reportedly wrote, “I can see no possibility that Cosby’s deposition could be used in a state criminal case, because I would have to testify as to what happened, and the deposition would be subject to suppression.” Current Montgomery County District Attorney Kevin Steele suggested to CNN that the email would not hurt the case against Cosby, however. “There is a specific legal method to grant immunity,” Steele said. “That was not done in 2005.”

The Associated Press reported a judge will have to decide if the agreement reached by Castor constitutes an immunity deal. Castor is expected to be a key defense witness at a Feb. 2 hearing to decide whether the case will be thrown out.