     
     func scrollViewDidScroll(_ scrollView: UIScrollView) {
         if PageViewController.currentPage == 0 && scrollView.contentOffset.x < scrollView.bounds.size.width {
-            scrollView.contentOffset = CGPoint(x: CGFloat(scrollView.bounds.size.width), y: CGFloat(0))
+            scrollView.contentOffset = CGPoint(x: scrollView.bounds.size.width, y: 0)
         }
         else if PageViewController.currentPage == 2 && scrollView.contentOffset.x > scrollView.bounds.size.width {
-            scrollView.contentOffset = CGPoint(x: CGFloat(scrollView.bounds.size.width), y: CGFloat(0))
+            scrollView.contentOffset = CGPoint(x: scrollView.bounds.size.width, y: 0)
         }
         
+    }
+    
+    func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) {
+        if PageViewController.currentPage == 0 && scrollView.contentOffset.x < scrollView.bounds.size.width {
+            scrollView.contentOffset = CGPoint(x: scrollView.bounds.size.width, y: 0)
+        } else if PageViewController.currentPage == 2 && scrollView.contentOffset.x > scrollView.bounds.size.width {
+            scrollView.contentOffset = CGPoint(x: scrollView.bounds.size.width, y: 0)
+        }
     }
     
     //array to reference the view controllers to page through

        dataSource = self
        
        for view: UIView in view.subviews {
            if (view is UIScrollView) {
                (view as? UIScrollView)?.delegate = self
                break
            }
        }
        

    
    func pageViewController(_ pageViewController: UIPageViewController, viewControllerAfter viewController: UIViewController) -> UIViewController? {
        
        guard let viewControllerIndex = orderedViewControllers.index(of: viewController) else {
            return nil
        }
        
        PageViewController.currentPage += 1
        
        if PageViewController.currentPage != viewControllerIndex {
            PageViewController.currentPage = viewControllerIndex
        }
        
        if PageViewController.currentPage > 2 {
            PageViewController.currentPage = 2
        }
        
        let nextIndex = viewControllerIndex + 1
