Fixed event listener bug