moved the listener stuff to a separate helper class