increment i correctly