events code style refactoring