Refactoring removeAllListeners method