Refactoring number validation