function [cGenAll] = add_names_cGen(cGenAll,barcodeGen)
for i = 1:numel(cGenAll)
    % Get the list of indices for this cell
    if numel(cGenAll)==1
    idxList= cGenAll.idx;
    else
    idxList = cGenAll{i}.idx;
    end

    % Preallocate cell array for names
    nameList = cell(1, numel(idxList));

    % Fill nameList using the idx's
    for k = 1:numel(idxList)
        nameList{k} = barcodeGen{idxList(k)}.name;
    end

    % Add to new field in cGenAll
    if numel(cGenAll)==1
    cGenAll.names = nameList;
    else
    cGenAll{i}.names = nameList;
    end
    
    
end
end