I think you should study up on variable scope. Each of your variables that are named i are actually different variables, because of scope.

Jim