moved for loop iterator out to for c89 compatibility