Refactor addEvents