         self.headerButton.setBackgroundImage(#imageLiteral(resourceName: "add_button_highlight"), for: .highlighted)
     }
     
+    private func distanceBetween(pointA: CGPoint, pointB: CGPoint) -> Double {
+        let distanceX = Double(pointA.x - pointB.x)
+        let distanceY = Double(pointA.y - pointB.y)
+        return sqrt(distanceX * distanceX + distanceY * distanceY)
+    }
+    
     // MARK: Public methods
     public func generate() {
+        for view in self.tagViews {
+            view.removeFromSuperview()
+        }
+        
+        tagViews.removeAll()
+        
         for title in self.tagTitles {
             let tagView = TagView(title: title)
             self.contentView.addSubview(tagView)

    override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
        if let originalTagView = originalTagView,
            let draggedTagView = draggedTagView {

            UIView.animate(withDuration: 0.3, animations: {
                let destCenter = self.contentView.convert(originalTagView.center, to: self)
                draggedTagView.center = destCenter
            }, completion: { (_) in
                draggedTagView.removeFromSuperview()
                originalTagView.alpha = 1
            })

        }

    }
    
    override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {

                currentMaxWidth = 0
            }
            
            tag.snp.remakeConstraints({ (make) in
                make.width.equalTo(tagWidth)
                make.height.equalTo(TagView.tagHeight)
                make.left.equalToSuperview().offset(currentMaxWidth + margin)
