Added safeguard for user input

try catch added for program stability