The criminal case against Bill Cosby may go on, Montgomery County Court of Common Pleas Judge Steven T. O’Neill ruled Wednesday, denying Cosby’s petition for writ of habeas corpus, in which he had argued that he could not be prosecuted pursuant to a 2005 agreement with the former Montgomery County district attorney.

After hearing from both the defense and the prosecutors on Cosby’s petition Tuesday and Wednesday, O’Neill decided in favor of the Montgomery County District Attorney’s Office, which has charged Cosby with one count of aggravated indecent assault.