     // carousel view controller delegate
     public var delegate : CMLazyScrollViewControllerDelegate? {
         didSet {
-            self.reload()
+            reload()
         }
     }
 
     // MARK: - PUBLIC FUNCTIONS
     // remove all views and rebuild the carousel
     public func reload() {
-        if let delegate = self.delegate {
-
-            self.pageSize = self.view.frame.size
-            self.cleanArray()
-
-            self.numberOfViews = delegate.numberOfViewControllersIn(scrollViewController: self)
-            self.pageControl.numberOfPages = self.numberOfViews
-            if self.infinite == true {
-                self.numberOfViews += 2
-            }
-
-            let width = (self.scrollDirection == .Horizontal) ? CGFloat(self.numberOfViews)*self.pageSize.width : self.pageSize.width
-            let height = (self.scrollDirection == .Horizontal) ? self.pageSize.height : CGFloat(self.numberOfViews)*self.pageSize.height
-            self.scrollView.contentSize = CGSize(width: width, height: height)
-            self.viewControllers = Array(repeating: nil, count: self.numberOfViews)
-            self.views = Array(repeating: nil, count: self.numberOfViews)
-
-
-            let x = (self.infinite == true && self.scrollDirection == .Horizontal) ? self.pageSize.width : 0
-            let y = (self.infinite == true && self.scrollDirection == .Vertical) ? self.pageSize.height : 0
-
-            self.scrollView.contentOffset = CGPoint(x: x, y: y)
-            self.currentIndex = (self.infinite == true) ? 1 : 0
-            self.updateCarousel()
+        if let delegate = delegate {
+
+            pageSize = view.frame.size
+            cleanArray()
+
+            numberOfViews = delegate.numberOfViewControllersIn(scrollViewController: self)
+            pageControl.numberOfPages = numberOfViews
+            if infinite == true {
+                numberOfViews += 2
+            }
+
+            let width = (scrollDirection == .Horizontal) ? CGFloat(numberOfViews)*pageSize.width : pageSize.width
+            let height = (scrollDirection == .Horizontal) ? pageSize.height : CGFloat(numberOfViews)*pageSize.height
+            scrollView.contentSize = CGSize(width: width, height: height)
+            viewControllers = Array(repeating: nil, count: numberOfViews)
+            views = Array(repeating: nil, count: numberOfViews)
+
+
+            let x = (infinite == true && scrollDirection == .Horizontal) ? pageSize.width : 0
+            let y = (infinite == true && scrollDirection == .Vertical) ? pageSize.height : 0
+
+            scrollView.contentOffset = CGPoint(x: x, y: y)
+            currentIndex = (infinite == true) ? 1 : 0
+            updateCarousel()
         }
     }
 
     // MARK: - PRIVATE FUNCTIONS
     fileprivate func requestAndAddViewControllerAt(index : Int) {
-        let fixedIndex = self.fixIndex(index: index)
+        let fixedIndex = fixIndex(index: index)
         var vc : UIViewController!
 
-        if self.viewControllers[index] != nil {
-            vc = self.viewControllers[index]!
+        if viewControllers[index] != nil {
+            vc = viewControllers[index]!
         } else {
-            vc = self.delegate?.viewControllerIn(scrollViewController: self, atIndex: fixedIndex) ?? UIViewController()
+            vc = delegate?.viewControllerIn(scrollViewController: self, atIndex: fixedIndex) ?? UIViewController()
         }
 
         // force frame to the size of a page
-        vc.view.frame = CGRect(x: 0.0, y: 0.0, width: self.pageSize.width, height: self.pageSize.height)
-        self.addChildViewController(vc)
-
-        let x : CGFloat = (self.scrollDirection == .Horizontal) ? CGFloat(index)*self.pageSize.width : 0.0
-        let y : CGFloat = (self.scrollDirection == .Horizontal) ? 0.0 : CGFloat(index)*self.pageSize.height
+        vc.view.frame = CGRect(x: 0.0, y: 0.0, width: pageSize.width, height: pageSize.height)
+        addChildViewController(vc)
+
+        let x : CGFloat = (scrollDirection == .Horizontal) ? CGFloat(index)*pageSize.width : 0.0
+        let y : CGFloat = (scrollDirection == .Horizontal) ? 0.0 : CGFloat(index)*pageSize.height
         // TODO: if i dont use a view here the constraint from the vc.view will break because of the scrollView, i tried to do some autolayout with the views i added but no success :(
-        let view = UIView(frame: CGRect(x: x, y: y, width: self.pageSize.width, height: self.pageSize.height))
+        let view = UIView(frame: CGRect(x: x, y: y, width: pageSize.width, height: pageSize.height))
         view.tag = index
         view.addSubview(vc.view)
 
-        self.scrollView.addSubview(view)
-        self.views[index] = view
-        self.viewControllers[index] = vc
+        scrollView.addSubview(view)
+        views[index] = view
+        viewControllers[index] = vc
         vc.didMove(toParentViewController: self)
     }
 

    override public func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
        self.viewControllers.removeAll()
        self.views.removeAll()
    }

    // MARK: - SCROLLVIEWDELEGATE

    public func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
        if (self.currentIndex-2 >= 0) {
            self.clearSlot(index: self.currentIndex-2)
        }
        if (self.currentIndex+2 < self.numberOfViews-1) {
            self.clearSlot(index: self.currentIndex+2)
        }
        self.scrollDelegate?.scrollViewDidEndDecelerating?(scrollView)
    }

    public func scrollViewDidScroll(_ scrollView: UIScrollView) {
        let page = (self.scrollDirection == .Horizontal) ? (scrollView.contentOffset.x + (0.5 * self.pageSize.width)) / self.pageSize.width : (scrollView.contentOffset.y + (0.5 * self.pageSize.height)) / self.pageSize.height

        self.currentIndex = Int(page)
        self.pageControl.currentPage = self.fixIndex(index: self.currentIndex)

        // last element, only for infinite mode
        if (self.infinite == true) {
            (self.scrollDirection == .Horizontal) ? self.checkDidScrollInfiniteModeWithX(scrollView: scrollView) : self.checkDidScrollInfiniteModeWithY(scrollView: scrollView)
        }

        self.lastScrollViewOffset = self.scrollView.contentOffset
        self.scrollDelegate?.scrollViewDidScroll?(scrollView)
    }

    public func scrollViewDidZoom(_ scrollView: UIScrollView) {
        self.scrollDelegate?.scrollViewDidZoom?(scrollView)
    }

    public func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
        self.scrollDelegate?.scrollViewWillBeginDragging?(scrollView)
    }

    public func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) {
        self.targetContentOffset = targetContentOffset.pointee
        self.scrollDelegate?.scrollViewWillEndDragging?(scrollView, withVelocity: velocity, targetContentOffset: targetContentOffset)
    }

    public func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) {
        self.scrollDelegate?.scrollViewDidEndDragging?(scrollView, willDecelerate: decelerate)
    }

    public func scrollViewWillBeginDecelerating(_ scrollView: UIScrollView) {
        self.scrollDelegate?.scrollViewWillBeginDecelerating?(scrollView)
    }

    public func scrollViewDidEndScrollingAnimation(_ scrollView: UIScrollView) {
        self.scrollDelegate?.scrollViewDidEndScrollingAnimation?(scrollView)
    }

    public func viewForZooming(in scrollView: UIScrollView) -> UIView? {
        return self.scrollDelegate?.viewForZooming?(in: scrollView)
    }

    public func scrollViewWillBeginZooming(_ scrollView: UIScrollView, with view: UIView?) {
        self.scrollDelegate?.scrollViewWillBeginZooming?(scrollView, with: view)
    }

    public func scrollViewDidEndZooming(_ scrollView: UIScrollView, with view: UIView?, atScale scale: CGFloat) {
        self.scrollDelegate?.scrollViewDidEndZooming?(scrollView, with: view, atScale: scale)
    }

    public func scrollViewShouldScrollToTop(_ scrollView: UIScrollView) -> Bool {
        if let bool = self.scrollDelegate?.scrollViewShouldScrollToTop?(scrollView) {
            return bool
        }
        return true
    }

    public func scrollViewDidScrollToTop(_ scrollView: UIScrollView) {
        self.scrollDelegate?.scrollViewDidScrollToTop?(scrollView)
    }

    public func screenDidRotate() {
        self.pageSize = self.view.frame.size
        let width = (self.scrollDirection == .Horizontal) ? CGFloat(self.numberOfViews)*self.pageSize.width : self.pageSize.width
        let height = (self.scrollDirection == .Horizontal) ? self.pageSize.height : CGFloat(self.numberOfViews)*self.pageSize.height
        self.scrollView.contentSize = CGSize(width: width, height: height)

        for view in self.views {
            if let view = view {
                let index : Int = view.tag
                let x : CGFloat = (self.scrollDirection == .Horizontal) ? CGFloat(index)*self.pageSize.width : 0.0
                let y : CGFloat = (self.scrollDirection == .Horizontal) ? 0.0 : CGFloat(index)*self.pageSize.height
                view.frame = CGRect(x: x, y: y, width: self.pageSize.width, height: self.pageSize.height)
            }
        }
        self.setCurrentPage(newValue: self.currentIndex, animated: false)
    }
}



    public var pageControlPosition : CMPageControlPosition = .Bottom {
        didSet {
            refreshPageControlConstraint()
        }
    }

