Very strange problem in for's

So this is my code, it generates a matrix of cells (blocks)

the types are:

        private Transform[,] field;	
	private myCell[] cellMap;
        private int[,] fieldMap;
	public myCell[] cells;

the code is:

counter = 0;
		for ( int i = 0; i < width; i ++ ) {
			for ( int j = 0; j < height; j ++ ) {
				int id = fieldMap[i,j];
				cellMap[counter] = cells[id];
				cellMap[counter].transform = ((Transform)Instantiate( cellMap[counter].transform, field[i,j].position, Quaternion.Euler(90,Random.Range(0,4) * 90,0)));
				Destroy (field[i,j].gameObject);
				cellMap[counter].transform.name = counter + "";
				cellMap[counter].transform.rotation = Quaternion.Euler(cells[id].rotation + new Vector3(0, Random.Range (0,4) * 90, 0));
				cellMap[counter].transform.tag = Tags.Cell;
				cellMap[counter].transform.parent = transform;
				
				counter++;
			}
		}

so now cellMap should contain a update list of ALL transforms generated, but it doesnt…
when i call this:

		for ( int i = 0; i < cellMap.Length; i ++ ) {
			Destroy( cellMap[i].transform.gameObject );
		}

it destroys the last few blocks (few random blocks with id ~220, the amount if 225)

You dont appear to have initialised cellmap[ ]
you need to have cellmap = new myCell[someLength];
where somelength is probably going to be width*height

also you probably need to
cellmap[counter] = new myCell ();

all initiators are in the Start() located, this part of code is triggered later on by a button.

and when i Debug.log, in the first for’s when i assign the cellmap and log just after that their name, its all good, but in the second for when i log their names before destroying, all from cellmap[0] to cellmap[width * height] are the transform around ~220

im sticking with

at line 5, cellMap[counter] = cells[id]; doesnt meant “copy cells[id] into cellmap[counter]”, it means “cellmap[counter] is cells[id]”