change var token to window.token