I am adding a listener in a function, but before doing so I am removing any old listeners. I think the removing is not working because it keeps calling the listener function