     // MARK: - Functions
     
     private func loopedPageForPage(page: Int) -> Int {
-        var loopedPage = page
-        if page > pageCount - 1 {
-            loopedPage = 0
-        } else if page < 0 {
-            loopedPage = pageCount - 1
-        }
-        return loopedPage
+        return page < 0 || pageCount == 0 ? pageCount + page : page % pageCount
+    }
+    
+    func pageForIndexPath(indexPath: NSIndexPath) -> Int {
+        var page = indexPath.row
+        if shouldLoop {
+            page -= 1
+            page = loopedPageForPage(page)
+        }
+        return page
     }
     
     // MARK: - UIViewController

    override func collectionView(collectionView: UICollectionView,
                                 numberOfItemsInSection section: Int) -> Int
    {
        return loopedCellIdentifiers?.count ?? 0
    }
    
    override func collectionView(collectionView: UICollectionView,
                                 cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell
    {
        let reuseIdentifier = loopedCellIdentifiers![indexPath.row]
        let cell = collectionView.dequeueReusableCellWithReuseIdentifier(reuseIdentifier, forIndexPath: indexPath)
        return cell
    }
    
}

        }
    }
    
    // MARK: - Override in subclass for dynamic content

    /// Override in subclass for dynamic content or use default implementation for static content.
    var pageCount: Int {
        return cellIdentifiers?.count ?? 0
    }
    
    /// Override in subclass for dynamic content or use default implementation for static content.
    override func collectionView(collectionView: UICollectionView,
                                 cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell
    {
        let page = pageForIndexPath(indexPath)
        let cellIdentifier = cellIdentifiers![page]
        let cell = collectionView.dequeueReusableCellWithReuseIdentifier(cellIdentifier, forIndexPath: indexPath)
        return cell
    }
    
    // MARK: - Variables
    
    var currentPage: Int {
        return Int(round(currentPageFloat))
    }
    
    var currentPageFloat: CGFloat {
        return currentCellItem - (shouldLoop ? 1 : 0)
    }
    
    var pageControl = UIPageControl()
    var collectionViewSize: CGSize?
    
    // MARK: - Private variables
    
    private var shouldLoop: Bool {
        return looped && pageCount > 1
    }
    
    private var currentCellItem: CGFloat {
        return collectionView!.contentOffset.x / collectionViewSize!.width
    }
    
    // MARK: - Actions
