fixed for loop over range(n)