Removed not required variable
Added more event names
Standardized event handler for the error event
Implemented more events