Refactored for general event listener.