Bill Cosby is not off the hook yet. A judge in Philadelphia on Wednesday ruled against Cosby's lawyers' request to dismiss the criminal rape case against the comedian because of some deal Cosby thought he made with prosecutors back in 2005, USA Today reports.

Back then, Cosby made an agreement with District Attorney Bruce Castor that said Cosby would never face criminal charges for allegedly raping Andrea Constand in 2004, as long as Cosby agreed to testify in the civil lawsuit Constand was bringing against him at the time.

But Castor isn't the D.A. anymore, and Judge Steven O'Neill said that old deal is basically B.S., since Castor didn't even have the authority to make it.

That means prosecutors can move forward with their case against Cosby. The next step is a hearing on March 8 when the court will begin determining if there's actually enough evidence to put Cosby on trial. 

Cosby is charged with  aggravated indecent assault, and accused of drugging and molesting Constand. After the judge ruled against him, Cosby buried his face in his hands, then reportedly walked down the courthouse steps using a cane as his lawyers put their arms around the 78-year-old comedian to comfort him.