Bug Fix: forgot to set `i` as local variable.