your i var is leaking into `window` here