AI pathfinding waypoints

Ive implemented a simple script for random movement between waypoints with a random wait time between each, the problem is the AI seems a little “indecisive”, at the start of movement the ai doesnt decide right away which waypoint to go to. It’s starting to walk in multiple directions before it decides “thats the waypoint im going to”.

anyone see a fix for this?

this is the script:

private bool isDeciding;

void Start () {
		agent = GetComponent<NavMeshAgent> ();
	// Update is called once per frame
	void Update () {
		if (GetComponent<NpcTalk> ().isTalking ) {
		if (!GetComponent<NpcTalk> ().isTalking) {
		if (isWaiting) {

		if (agent.remainingDistance <= agent.stoppingDistance) {
			isMoving = false;
			isWaiting = true;
		//agent.SetDestination (GameObject.FindGameObjectWithTag ("Player").transform.position);

	private IEnumerator WaitOrMove () {
        isDeciding = true;
		yield return new WaitForSeconds (Random.Range (1, 3));
		int r = Random.Range (0, 6);
		isMoving = true;
		isWaiting = false; 
        isDeciding = false;

EDIT: edited the script with answer

Add another bool “isDeciding” and set it to true before the yield WaitforSeconds line. Only call WaitOrMove if isDeciding is set to false.