NavMeshAgent keeps changing because of Vector3

So, i made a script for my NavMeshAgent, and in it, i get the size of the floor, get two random points within that, an X and a Z and set that to be the random position. i then set the navmeshagent’s destination to that position. i added a gizmo to see where the destination was, and everything was working fine. then i went to make some changes, and removed the two lines of gizmo code at the bottom of my function. after this the destination keeps changing every few seconds for no reason. after it changes a dozen times or so it settles on one destinations, once it reaches it the changing starts again. why is this?
This is the code for the agent:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;

public class BotMovement : MonoBehaviour
{
    //Time before the bot moves to its next location
    public float minWaitTime = 2f;
    public float maxWaitTime = 5f;

    //Gets floor object and the bounds
    public GameObject floorObject = null;
    private Bounds bounds;

    private NavMeshAgent nma = null;

    public Vector3 test;

    private void Start()
    {
        nma = this.GetComponent<NavMeshAgent>();
        bounds = floorObject.GetComponent<Renderer>().bounds;
    }

    private void Update ()
    {
        if(nma.hasPath == false || nma.remainingDistance < 1.0f)
        {
            float waitTime = Random.Range(minWaitTime, maxWaitTime);
            Invoke("SetRandomDestination", waitTime);
        }

    }

    private void SetRandomDestination()
    {
        float randomX = Random.Range(bounds.min.x, bounds.max.x);
        float randomZ = Random.Range(bounds.min.z, bounds.max.z);
        Vector3 randomPosition = new Vector3(randomX, this.transform.position.y, randomZ);

        nma.SetDestination(randomPosition);

        test = randomPosition;
      
        Gizmos.color = Color.red;
        Gizmos.DrawWireSphere(randomPosition, 50f);
    }
}

Whenever i remove the lines of gizmo, the random position keeps changing

UPDATE!!:
after mucking around for a little bit i think the problem might be with the invoke. i think it is waiting the waittime before the random destination is set, so for that whole wait time it is finding a new position until that time is up. how could i fix this? its got nothing to do with the gizmos at all

After mucking around further, after realising what the problem was, i came to a solution on my own. i figured i might as well put it in here in case any one is interested. because the invoke was messing stuff up, and making the destination reset itself until the time was up, i created a CoRoutine and at the beginning i set the speed of the agent to 0. then it got the destination, waited for the random time then set the speed back to normal, this way the destination is set and the agent still waits!
using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices.WindowsRuntime;
using UnityEngine;
using UnityEngine.AI;

public class BotMovement : MonoBehaviour
{
    //Time before the bot moves to its next location
    public float minWaitTime = 2f;
    public float maxWaitTime = 5f;

    //Gets floor object and the bounds
    public GameObject floorObject = null;
    private Bounds bounds;

    private NavMeshAgent nma = null;

    public Vector3 randomPosition;

    private void Start()
    {
        nma = this.GetComponent<NavMeshAgent>();
        bounds = floorObject.GetComponent<Renderer>().bounds;
    }

    private void Update ()
    {
        if(nma.hasPath == false || nma.remainingDistance < 1.0f)
        {
            StartCoroutine(SetRandomDestination());
        }

    }

    private IEnumerator SetRandomDestination()
    {
        float waitTime = Random.Range(minWaitTime, maxWaitTime);
        nma.speed = 0f;

        float randomX = Random.Range(bounds.min.x, bounds.max.x);
        float randomZ = Random.Range(bounds.min.z, bounds.max.z);
        randomPosition = new Vector3 (randomX, this.transform.position.y, randomZ);

        nma.SetDestination(randomPosition);

        yield return new WaitForSeconds(waitTime);

        nma.speed = 5f;
    }

    public void OnDrawGizmos()
    {
        Gizmos.color = Color.red;
        Gizmos.DrawWireSphere(randomPosition, 0.5f);
    }
}

Every frame that the update happens during the “waitTime” the Invoke is called. For example if the wait time is 60s and the Update is running at 60FPS the Invoke gets called for 60 times until the first invoke call starts with setting the destination…

And even the SetDestination method sometimes needs more frames to calculate the path. I guess that hasPath returns false until the entire path is not calculated. You should probably use the NavMeshAgent.pathPending property too.

private void Update ()
     {
         if(nma.hasPath == false || nma.remainingDistance < 1.0f)
         {
             float waitTime = Random.Range(minWaitTime, maxWaitTime);
             Invoke("SetRandomDestination", waitTime);
         }
     }

I would guess that here is the main problem:
if(nma.hasPath == false || nma.remainingDistance < 1.0f)