Updated to work with listener.