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

        contentSectionScrollView.setContentOffset(contentSectionScrollView.contentOffset, animated: false)
    }
    
    private func setupPages() {
        // clear all caches
        cachedPageTabs.removeAll()

//   1. Performace improvement
//   2. Adjust the scrolling offset if tabs have diffent widths
//   3. Test reloadData function
//   4. Init with frame
//   5. Flexiable tab height
//   6. Tabs in the bottom

import UIKit

