refactoring and events