fixed some missing vars in for loops