 	}
 	
 	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 func pageViewController(_ pageViewController: UIPageViewController, viewControllerAfter viewController: UIViewController) -> UIViewController? {
		if let index = pages.index(of: viewController) {
			if index == pages.count - 1 {
				return self.cycleMode ? pages.first : nil


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