added var to for( i=0;...