Refactored to use try/catch on user input.