 	}
 	
 	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)

	}
	
	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]) {
