How to delete objects of a parent and then instantiate a new one?

So I’m trying to delete the objects of a parent and then replace the object and repeat. It works but sometimes deletes an object and then doesn’t replace it

public GameObject[] trnaSelectionArray;
public bool trnaStopInstantiation = false;
public GameObject parentedObject;

void Update()
{
    InstantiateTrna();
}

private void InstantiateTrna()
{

    if (trnaStopInstantiation)
    {
        foreach (Transform child in transform)
        {
            Destroy(child.gameObject);
        }
        Instantiate(trnaSelectionArray[Random.Range(0, trnaSelectionArray.Length)], parentedObject.transform.parent);
        trnaStopInstantiation = false;
    }
}

}

Put the instantiate method in the foreach loop.