added try catch, and i think something is wrong with the program from the book