Bill Cosby is seeking to have the felony charge against him dismissed, or at least to have the Montgomery County District Attorney’s Office disqualified from the prosecution.

Attorneys for Cosby filed a petition for a writ of habeas corpus and motion to disqualify in the Montgomery County Court of Common Pleas on Monday. He argued that he had an express agreement with the District Attorney’s Office in 2005, through then-District Attorney Bruce Castor, in which the commonwealth said Cosby would never be prosecuted with respect to allegations of sexual assault by Andrea Constand, who later sued Cosby and agreed to a confidential settlement in 2006.