refactor listener object and move it to its own file