Fixes bug in checkValidNumber function