     }
 
     private func changeFilter(tag: Int, state: NSControl.StateValue) {
+        guard let midiDocument = midiDocument else { return }
+
         let turnBitsOn: Bool
         switch state {
         case .on, .mixed:

    }

    @IBAction func setChannel(_ sender: Any?) {
        if let control = sender as? NSControl {
            let channel = (control.objectValue as? NSNumber)?.intValue ?? 0
            midiDocument.showOnlyOneChannel(channel)

    }

    @IBAction func setChannelRadioButton(_ sender: Any?) {
        guard let midiDocument = midiDocument else { return }

        if let matrix = sender as? NSMatrix {
            if matrix.selectedCell()?.tag == 0 {
                midiDocument.showAllChannels()
