Fixed bug with event listeners not working