         if let count = stories?.count {
             if n < count {
                 //Move to next story
+                manualScrollEnabled = false
                 nStoryIndex = nStoryIndex + 1
                 let nIndexPath = IndexPath.init(row: nStoryIndex, section: 0)
+                lastIndex = nIndexPath
                 collectionview.scrollToItem(at: nIndexPath, at: .right, animated: true)
             }else {
                 self.dismiss(animated: true, completion: nil)

        let cell = cell as? IGStoryPreviewCell
        cell?.storyHeaderView?.generateSnappers()
        cell?.snapIndex = 0
    }
    
    func collectionView(_ collectionView: UICollectionView, didEndDisplaying cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
        let cell = cell as? IGStoryPreviewCell
//        cell?.storyHeaderView?.cancelTimers(snapIndex: (cell?.snapIndex)!)
    }
    
    func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
        let pageWidth = scrollView.frame.size.width
        let fractionalPage = scrollView.contentOffset.x / pageWidth
        let page = lroundf(Float(fractionalPage))
        self.lastContentOffset = scrollView.contentOffset
        if let count = stories?.count {
            let f_count = count-handPickedStoryIndex
            if page == 0 && scrollView.panGestureRecognizer.translation(in: scrollView.superview).x < 0 {
                let t = nStoryIndex + 1
                if t < f_count {
                     nStoryIndex = nStoryIndex + 1
                    self.manualScrollDirection = internalScrollType.right.rawValue
                }
                //print("Begin start nStoryIndex:\(nStoryIndex)")
            }else if page != 0 && page != f_count-1 {
                //Here we will be able to get to which kind of scroll user is trying to do!. check(Left.Horizontl.Scroll)
                if scrollView.panGestureRecognizer.translation(in: scrollView.superview).x > 0 {
                    //if user do back scroll then we reducing -1 from iteration value
                    let t = nStoryIndex - 1
                    if t > f_count {
                        nStoryIndex = nStoryIndex - 1
                        self.manualScrollDirection = internalScrollType.left.rawValue
                    }
                }else {
                    //check(Right.Horizontl.Scroll)
                    //if user do front scroll then we adding +1 from iteration value
                    let t = nStoryIndex + 1
                    if t < f_count {
                        nStoryIndex = nStoryIndex + 1 // go to next story
                        self.manualScrollDirection = internalScrollType.right.rawValue
                    }
                }
            }else if page == f_count-1 && scrollView.panGestureRecognizer.translation(in: scrollView.superview).x > 0 {
                let t = nStoryIndex - 1
                if t > f_count {
                    nStoryIndex = nStoryIndex - 1
                    self.manualScrollDirection = internalScrollType.left.rawValue
                }
            }else if page == 0 || page == f_count-1 {
                self.manualScrollDirection = internalScrollType.notscrolled.rawValue
            }
        }
    }
    
    func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
        if self.lastContentOffset?.x ?? 0 == scrollView.contentOffset.x  {
//            print("Manual scroll direction:\(self.manualScrollDirection!)")
            if self.manualScrollDirection == internalScrollType.left.rawValue {
                let t = nStoryIndex + 1
                if t < (stories?.count)!-handPickedStoryIndex {
                    nStoryIndex = nStoryIndex + 1
                }
//                print("End nStoryIndex:\(nStoryIndex)")
            }
            else if self.manualScrollDirection == internalScrollType.right.rawValue {
                let t = nStoryIndex - 1
                if t > (stories?.count)!-handPickedStoryIndex {
                    nStoryIndex = nStoryIndex - 1
                }
//                print("End nStoryIndex:\(nStoryIndex)")
            }
        }
    }
}

                fatalError("Stories Index mis-matched :(")
            }
        }
        lastIndex = indexPath
        return cell
    }
    
