added functions to clean code

added functions to clean code but its a bit buggy when user inputs a
letter instead of digit. Program needs input validation system.