Duplicate var definition for i (repeated below a bunch too).