manage the isRunning flag