     }
     
     public func scrollViewWillBeginDecelerating(scrollView: UIScrollView) {
-        updateDirection()
+        determineDirection(scrollView)
     }
     
     public func scrollViewWillEndDragging(scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) {
         log("\(#function): \(scrollView.contentOffset.x), velocity: \(velocity.x), target: \(targetContentOffset.memory.x)")
-        updateDirection(withHorizontalVelocity: velocity.x)
+        determineDirection(withHorizontalVelocity: velocity.x)
     }
     
     public func scrollViewDidEndDragging(scrollView: UIScrollView, willDecelerate decelerate: Bool) {
-        updateDirection()
         if !decelerate {
             if let indexPath = self.indexPathForItemAtPoint(scrollView.contentOffset) {
                 log("\(#function)[\(self.tag)]: real -> \(indexPath.row)")

    private var pageControl: UIPageControl!
    private var collectionLayout: HFSwipeViewFlowLayout?
    
    // MARK: Loop Control Variables
    private var notifyWhileScrolling: Bool = true
    private var lastX: CGFloat = 0
    private var lastDirection: UIRectEdge = .Left
    private var dummyCount: Int = 0
    private var dummyWidth: CGFloat = 0
    private var realViewCount: Int = 0                  // real item count includes fake views on both side
    private var currentRealPage: Int = -1
    private var tapGesture: UITapGestureRecognizer?
    

        } else {
            contentSize.width = ceil((itemSize.width + itemSpace) * CGFloat(itemCount + dummyCount * 2) - itemSpace)
        }
        collectionLayout!.estimatedItemSize = itemSize
        collectionLayout!.itemSize = itemSize
        collectionView!.contentSize = contentSize
        log("successfully set content size: \(self.collectionView!.contentSize)")
        
        return true
    }
}

