Added error handling for createEvent