cleaned up code messages event listener not working