When it appears, at any time before verdict or judgment, that a mistake has been made in charging the proper offense, the defendant must not be discharged, if there appears good cause to detain the defendant in custody, but the court shall commit the defendant, or require the defendant to give bail for the defendant's appearance to answer to the offense, and also may require the witnesses to give bail for their appearance. The provisions of rule 12 of the North Dakota Rules of Criminal Procedure as to the manner and time of prosecution, so far as applicable, govern the further proceedings under this section.
N.D.C.C. § 29-21-15