bug fix in trench for loop (using i now)