         return CGSize(width: bounds.size.width * CGFloat(numberOfPhotos()), height: bounds.size.height)
     }
     
-    private func contentOffsetForPage(AtIndex index: Int) -> CGPoint {
+    private func contentOffsetForPage(atIndex index: Int) -> CGPoint {
         let pageWidth = pagingScrollView.bounds.size.width
         let newOffset = CGFloat(index) * pageWidth
         return CGPoint(x: newOffset, y: 0)
     }
     
     private func centerContentOffsetToMiddleSegment() {
+        if numberOfPhotos() == 0 { return }
+        
         _currentPageIndex = (_currentPageIndex % realNumberOfPhotos()) + realNumberOfPhotos()
-        let pageFrame = frameForPage(AtIndex: _currentPageIndex)
+        let pageFrame = frameForPage(atIndex: _currentPageIndex)
         
         pagingScrollView.setContentOffset(CGPoint(x: pageFrame.origin.x - PADDING, y: 0), animated: false)
     }

    }
    
    private func configurePage(_ page: OTTOZoomingScrollView, forIndex index: Int) {
        page.frame = frameForPage(AtIndex: index)
        page.tag = TAG_OFFSET + index
        page.photo = _photos[index]
    }
    
    private func didStartViewingPage(atIndex index: Int) {
        let photo = _photos[index]
        if photo.image == nil {
            loadAndDisplay(photo: photo)

        
        visiblePages.removeAll()
        
        pagingScrollView.contentOffset = contentOffsetForPage(atIndex: _currentPageIndex)
        createPages()
    }
    
