refactor listeningto into a directive