add win and winWidth variable and replace $(window) with win