     
     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
-        }
-        
-        guard let viewControllerIndex = orderedViewControllers.index(of: viewController) else {
-            return nil
         }
         
         let nextIndex = viewControllerIndex + 1

    
    func pageViewController(_ pageViewController: UIPageViewController, viewControllerBefore viewController: UIViewController) -> UIViewController? {
        
        PageViewController.currentPage -= 1
        
        guard PageViewController.currentPage >= 0 else {
            PageViewController.currentPage = 0
            return nil
        }
        
        guard let viewControllerIndex = orderedViewControllers.index(of: viewController) else {
            return nil
        }
        

    
    func scrollViewDidScroll(_ scrollView: UIScrollView) {
        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)
        }
        
    }
    
    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
