Now adds eventListener to document instead of window