       // Display the app menu.
       statusItem.popUpMenu(menu)
     }
-    // Disable the highlighting of the status bar item when
-    // the app menu closes.
+    // Set highlighted to false when the application menu closes.
     sender.isHighlighted = false
   }
 
   /// Either terminates or launches a caffeinate task, depending
   /// on whether a task is already running.
-  ///
-  /// - parameter sender: Status bar button that sends the action.
-  func toggleStatus(_ sender: NSStatusBarButton?) {
-    guard let sender = sender else {
-      return
-    }
-    // Check wether a caffeinate task is already
-    // running or not
-    if caffeinate.isRunning() {
-      // Terminate the running caffeinate task.
-      caffeinate.terminate()
-      // Let the menu bar icon appear disabled.
-      sender.appearsDisabled = true
+  func toggleStatus() {
+    if caffeine.active {
+      caffeine.decaffeinate()
     } else {
-      // Launch a new caffeinate task.
-      caffeinate.launch()
-      // Let the menu bar icon appea enabled.
-      sender.appearsDisabled = false
+      caffeine.caffeinate()
     }
   }
 

  /// - parameter sender: Object that wants Espresso to quit
  @IBAction func terminate(_ sender: AnyObject) {
    // Terminate the caffeinate task, in case we're running any.
    if let caffeinate = self.caffeinate {
      caffeinate.terminate()
    }

    // Send the terminate message.
    NSApplication.shared().terminate(self)
  }

      // Define the target of the click actions.
      statusBtn.target = self
      // Define the left click action.
      statusBtn.action = #selector(AppController.toggleStatus)
      // Set the status items button to appear disabled
      // (transculant appearance)
      statusBtn.appearsDisabled = true
