added try and catch

added try and catch to prevent crash