     {
         print("Start")
         midResult = getMidFromFiles()
-        runCountdown()
+        if isStarted == false {
+            runCountdown()
+        }
     }
     
     @IBAction func onEndClick(_ sender: NSButton)
     {
         print("Stop")
         myTimer.invalidate()
+        isStarted = false
         midTextField.stringValue = midResult
         
     }


class ViewController: NSViewController {

    var pathString: String?
    let fm = FileManager.default
    var myTimer = Timer()

    }
    
    func runCountdown() {
        isStarted = true
        myTimer = Timer.scheduledTimer(timeInterval: 0.125, target: self, selector:#selector(ViewController.randomMid), userInfo: nil, repeats: true)
    }
    
