added try/catch to onSubmit