Updated the window event listener