"dispatch event" refactoring