Fixed bug with event listeners