Refactor listener.