Moved all listening code to Listener class.