 
     private func update() {
 
-        var items:[ItemView] = []
-        
-        if currentPage < displayCount {
-            for index in -2..<(displayCount+2) {
-                let item = ItemView(itemSize: itemSize, dotSize: dotSize, index: index)
-                items.append(item)
-            }
-            self.items = items
+        if currentPage < config.displayCount {
+
+            items = (-2..<(config.displayCount+2))
+                .map { ItemView(itemSize: itemSize, dotSize: config.dotSize, index: $0) }
         } else {
-            guard let firstItem = self.items.first else { return }
-            guard let lastItem = self.items.last else { return }
-            
-            for index in firstItem.index...lastItem.index {
-                let item = ItemView(itemSize: itemSize, dotSize: dotSize, index: index)
-                items.append(item)
-            }
-            self.items = items
+
+            guard let firstItem = items.first else { return }
+            guard let lastItem = items.last else { return }
+            items = (firstItem.index...lastItem.index)
+                .map { ItemView(itemSize: itemSize, dotSize: config.dotSize, index: $0) }
         }
 
         scrollView.contentSize = CGSize(width: itemSize * CGFloat(numberOfPages), height: itemSize)

    private func setCurrentPage(currentPage: Int, animated: Bool) {

        updateDotColor(currentPage: currentPage)
        
        if canScroll {
            updateDotPosition(currentPage: currentPage, animated: animated)
            updateDotSize(currentPage: currentPage, animated: animated)
        }
    }
    
    private func updateDotColor(currentPage: Int) {
     
        for index in 0..<(displayCount + 4) {
            let pageIndex = items[index].index
            items[index].dotColor = (pageIndex == currentPage) ? currentPageIndicatorTintColor : pageIndicatorTintColor
        }
    }
    

            scrollView.addSubview(items[i])
        }

        let size = CGSize(width: itemSize * CGFloat(config.displayCount), height: itemSize)
        let frame = CGRect(origin: .zero, size: size)

        scrollView.frame = frame

        if config.displayCount < numberOfPages {
            scrollView.contentInset = UIEdgeInsets(top: 0, left: itemSize * 2, bottom: 0, right: itemSize * 2)
        } else {
            scrollView.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
