replace for(i = ... with for(i in ...