refactor listener