Refactor listener