ensuring the rights of the detainee in criminal proceedings