fix nested grid loop issue