refactored the switch statement, added functionality for removing the last number