code refactored in eventcontroller