check_number refactored