             
             let alpha = 1 - distance * swipeToDissmissFadeOutAccelerationFactor
             
-            closeButton.alpha = alpha
+            closeButton?.alpha = alpha
             headerView?.alpha = alpha
             footerView?.alpha = alpha
         }

public class GalleryViewController : UIPageViewController, UIViewControllerTransitioningDelegate, ImageViewControllerDelegate  {
    
    //UI
    private var closeButton: UIButton!
    public var headerView: UIView?
    public var footerView: UIView?
    

    public override func viewDidLayoutSubviews() {
        super.viewDidLayoutSubviews()
        
        closeButton?.frame.origin = CGPoint(x: self.view.frame.size.width - closeButton!.frame.size.width - closeButtonPadding, y: closeButtonPadding)
        
        layoutHeaderView()
        layoutFooterView()
