added try and catch