Added code to remove event listeners