refactoring for events and commands