improved error handling of events