     }
     
     @IBAction func pageTouchBarDidChange(_ sender: NSSegmentedControl) {
-        DatasourceController.shared.save()
-        DatasourceController.shared.currentViewIndex = sender.selectedSegment + 1
-        DatasourceController.shared.load()
-        
-        setupViewButtons()
+        changeView(viewIndex: sender.selectedSegment + 1)
     }
     
     func createDrawScene() {

        }
    }
    
    func syncUI() {
        contentTouchBarButton.selectedSegment = DatasourceController.shared.currentMode.rawValue
        contentModeButton.selectedSegment = DatasourceController.shared.currentMode.rawValue
        
        switch DatasourceController.shared.currentMode {
        case .text:
            removeDrawScene()
            showPlainText()

        }
    }
    
    func changeView(viewIndex: Int) {
        DatasourceController.shared.saveText()
        DatasourceController.shared.currentViewIndex = viewIndex
        DatasourceController.shared.loadNote()
    }
    
    @IBAction func changeView(_ sender: NSButton) {
        changeView(viewIndex: sender.tag)
    }

    @IBAction func viewDidChange(_ sender: NSPopUpButton) {
