refactored events to be an object