Added some code to implement the listener class