         let first = min(index, indexOfVisibleItem) + 1
         let last = max(index, indexOfVisibleItem)
         hideContent(forRange: first..<last)
-
-        let width = viewControllers[index].view.bounds.width
-        let contentOffsetX = width * CGFloat(index)
-        setContentOffset(CGPoint(x: contentOffsetX, y: contentOffset.y), animated: true)
+        updateContentOffset(withIndex: index)
     }
  
     public func reloadData() {

        }
        
        layoutContent()
    }
    
}

        }
    }
    
    private func updateContentOffset(withIndex index: Int) {
        if viewControllers.count > index {
            let width = viewControllers[index].view.bounds.width
            let contentOffsetX = width * CGFloat(index)
            setContentOffset(CGPoint(x: contentOffsetX, y: contentOffset.y), animated: true)
        }
    }
    
    func hideContent(forRange range: Range<Int>) {
        viewControllers.enumerate().forEach { index, viewController in
            viewController.view.hidden = range.contains(index)
