clean up check_input code