             leftButtonText = newText
             
             var updatedBarButtonItems : [UIBarButtonItem] = []
-            let leftBarButton: UIBarButtonItem = UIBarButtonItem(title: newText, style: .done, target: self, action:#selector(leftButtonAction))
-            
-            if showMaxCount ?? false {
-                leftBarButton.isEnabled = false
-            } else {
-                leftBarButton.isEnabled = true
-            }
-            
-            updatedBarButtonItems.append(leftBarButton)
+            // let leftBarButton: UIBarButtonItem = UIBarButtonItem(title: newText, style: .done, target: self, action:#selector(leftButtonAction))
+            
+            var leftBarButton : UIBarButtonItem? = UIBarButtonItem()
+            if let leftButtonText = leftButtonText {
+                leftBarButton = generateLeftBarButton(leftButtonText)
+            
+                if showMaxCount ?? false {
+                    leftBarButton?.isEnabled = false
+                } else {
+                    leftBarButton?.isEnabled = true
+                }
+            }
+            
+            updatedBarButtonItems.append(leftBarButton!)
             updatedBarButtonItems.append(barButtonItems[1])
             updatedBarButtonItems.append(barButtonItems[2])
             
+            textViewToolbar.items = nil;
             textViewToolbar.items = updatedBarButtonItems
             textViewToolbar.sizeToFit()
             

        var barButtonItems : [UIBarButtonItem] = []
    
        textViewToolbar.barStyle = .default
        
        let flexSpace = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil)
        
        if let leftButtonText = leftButtonText {
            let leftBarButton: UIBarButtonItem = UIBarButtonItem(title: leftButtonText, style: .done, target: self, action:#selector(leftButtonAction))
            
            if showMaxCount ?? false {
                leftBarButton.isEnabled = false

    
    public func updateRightButtonText(_ newText: String?) {
        
        
        
        if let barButtonItems = textViewToolbar.items, let newText = newText {
            
            var updatedBarButtonItems : [UIBarButtonItem] = []
            updatedBarButtonItems.append(barButtonItems[0])
            updatedBarButtonItems.append(barButtonItems[1])
            
            // clear current toolbar.
            textViewToolbar.items = nil;
            
            // build the updated right hand button.
            rightButtonText = newText
            
            //let rightBarButton: UIBarButtonItem = UIBarButtonItem(title: newText, style: .done, target: self, action:#selector(rightButtonAction))
            var rightBarButton: UIBarButtonItem = UIBarButtonItem()
            
            if let rightButtonText = rightButtonText {
                rightBarButton = generateRightBarButton(rightButtonText)
            }
            
//            rightBarButton.target = self
//            rightBarButton.action = #selector(rightButtonAction)
//
            
            updatedBarButtonItems.append(rightBarButton)
            
            textViewToolbar.items = updatedBarButtonItems
