fixed loop iterator to proper variable