removed global var i