fix check_code method