changed document.click to document.on("click")