Handles number format errors, exits program, eliminated duplication