     }
 
     func em_pageViewController(_ pageViewController: EMPageViewController, didFinishScrollingFrom startingViewController: UIViewController?, destinationViewController: UIViewController, direction: EMPageViewControllerNavigationDirection, transitionSuccessful: Bool) {
-        if let currentIndex = self.currentIndex , currentIndex < self.tabItemCount {
+        if let currentIndex = self.currentIndex, currentIndex < self.tabItemCount {
             self.tabView.updateCurrentIndex(currentIndex, shouldScroll: true)
             self.beforeIndex = currentIndex
             self.delegate?.pageMenuController?(self, didScrollToPageAtIndex: currentIndex, direction: direction.toPageMenuNavigationDirection)

    }

    fileprivate var tabItemCount: Int {
        return self.dataSource?.menuTitles(forPageMenuController: self).count ?? 0
    }

    public init(options: PageMenuOptions? = nil) {


        guard let titles = self.dataSource?.menuTitles(forPageMenuController: self),
              let viewControllers = self.dataSource?.viewControllers(forPageMenuController: self) else {
                return
        }

        if defaultIndex < 0 || defaultIndex >= titles.count || defaultIndex >= viewControllers.count {
