added check to handle InputMismatchException