Fix window.on error