Also added in flag to make sure the routine doesn't try to run more than one iteration simultaneously if a previous iteration is still running.
Also added in flag to make sure the routine doesn't try to run more than one iteration simultaneously if a previous iteration is still running.