         return limit
     }
     
-    private var pageIndex: Int {
-        get {
-            var index = -1
-            if (numberOfPages != 0) {
-                let currentOffset = tabSectionScrollView.contentOffset.x
-                var startOffset = 0 as CGFloat
-                var endOffset = (tabSectionScrollView.contentInset.left * -1) - (widthForTabAtIndex(0) / 2)
-                
-                var boundLeft = 0 as CGFloat
-                var boundRight = 0 as CGFloat
-                
-                for i in 0 ..< numberOfPages {
-                    startOffset = endOffset
-                    endOffset = startOffset + widthForTabAtIndex(i)
-                    
-                    if (i == 0) {
-                        boundLeft = startOffset
-                    }
-                    if (i == numberOfPages - 1) {
-                        boundRight = endOffset
-                    }
-                    
-                    if (startOffset <= currentOffset && currentOffset <= endOffset) {
-                        index = i
-                    }
-                }
-                
-                if (currentOffset < boundLeft) {
-                    index = 0
-                }
-                if (currentOffset > boundRight) {
-                    index = numberOfPages - 1
-                }
-            }
-            return index
-        }
-        set(index) {
-            if (numberOfPages != 0) {
-                var tabOffsetX = 0 as CGFloat
-                var contentOffsetX = 0 as CGFloat
-                for _ in 0 ..< index {
-                    tabOffsetX += widthForTabAtIndex(index)
-                    contentOffsetX += self.frame.width
-                }
-                // set default position of tabs and contents
-                tabSectionScrollView.contentOffset = CGPoint(x: tabOffsetX + tabSectionScrollView.contentInset.left * -1, y: tabSectionScrollView.contentOffset.y)
-                contentSectionScrollView.contentOffset = CGPoint(x: contentOffsetX  + contentSectionScrollView.contentInset.left * -1, y: contentSectionScrollView.contentOffset.y)
-                updateTabAppearance(animated: false)
-            }
-            prevPageIndex = index
-        }
-    }
-    
     private var isStarted = false
-    private var prevScrollingIndex: Int?
+    private var pageIndex: Int!
     private var prevPageIndex: Int?
     
     private var isWaitingForPageChangedCallback = false

            updateTabAppearance()
        }
        
        if (isStarted && prevScrollingIndex != pageIndex) {
            // lazy loading
            lazyLoadPages()
            
            prevScrollingIndex = pageIndex
            // callback
            delegate?.tabScrollView(self, didScrollPageTo: pageIndex)
        }
    }
    

    
    // scrolling animation stop with decelerating
    public func scrollViewDidEndDecelerating(scrollView: UIScrollView) {
        moveToIndex(properPageIndex(), animated: true)
    }
    
    // scrolling animation stop without decelerating
    public func scrollViewDidEndDragging(scrollView: UIScrollView, willDecelerate decelerate: Bool) {
        if (!decelerate) {
            moveToIndex(properPageIndex(), animated: true)
        }
    }
    
