Refactoring and custom trigger events