Refactored code to use Event model