perform refactoring in event handling