Removed io global declaration and added window reference instead