Endless Runner, wrong ground plane being destroyed

Hey everyone! I’m really new to Unity and C# and am creating an endless runner where I have the ground planes being loaded using Resources.Load. I have it set up where a random platform is chosen from the folder and instantiated ahead of the current ground plane when the player hits a trigger. I then have a destroy function to destroy the last ground plane if the ground selector I’ve set up goes above 2. However, when the ground selector does that the current ground plane that the player is on is the one that is being destroyed.
I think the problem is on lines 36-37, but I may be entirely wrong.
Any suggestions on how to get it to delete the previous ground plane and not the current one?

public class GroundGenerator : MonoBehaviour
{
//  private float [] groundsWidths;
  //public ObjectPooler[] thePool;
//  public ObstacleGenerator keepGoing;

GameObject[] groundPrefabs;

GameObject lastGround;

public GameObject currentGround;


//  private float distanceBetween = 0f;
  private int groundSelector = 0;
  private float zPos;
  private float yPos = -0.55f;

    // Start is called before the first frame update
    void Start()
    {
      groundPrefabs = Resources.LoadAll<GameObject>("Prefabs/grounds");

    }

    // Update is called once per frame
    public void GenerateNextGround(){


      groundSelector ++;

      GameObject nextGround = Instantiate(groundPrefabs[Random.Range(0,2)]);
      nextGround.name = "ground_" + groundSelector;
      nextGround.transform.position = new Vector3(0,yPos,groundSelector*600);

      lastGround = currentGround;
      currentGround = nextGround;


      if(groundSelector>2){
        Destroy(lastGround);
        groundSelector = 0;
      }
    }
 
}

I think if you move lines 40-43 so that they are before lines 36-37 it might be what you want.

After switching the lines it now stops generating platforms after the groundSelector>2