Declare i outside loop