rewrote event/error handling system