 	}
 	
 	open func pageViewController(_ pageViewController: UIPageViewController, viewControllerBefore viewController: UIViewController) -> UIViewController? {
+		if pages.count < 2 { return nil }
+		
 		if let index = pages.index(of: viewController) {
 			if index == 0 {
 				return self.cycleMode ? pages.last : nil


open class CLPageViewController: UIPageViewController, UIPageViewControllerDataSource, UIPageViewControllerDelegate {
	var pages:[UIViewController] = []
	var cycleMode:Bool = false
	open var onSelectPage:(Int) -> () = { _ in }
	
	open func setPages(pages:[UIViewController]) {

	}
	
	open func gotoPage(index:Int, direction:UIPageViewControllerNavigationDirection = .forward) {
		if pages.count < 2 { return }
		
		if index < pages.count {
			let page = pages[index]
			self.setViewControllers([page], direction: direction, animated: true, completion: nil)
