rewrite check_prog()