added error event
added end and fail hamdlers.  updated error handler