refactoring listeners to be less ugly