improved check_input