                 oldController.view.removeFromSuperview()
                 oldController.removeFromParentViewController()
             }
-            if let mainViewController = mainViewController {
-                let viewDictionary      = ["mainView" : mainViewController.view]
-                mainViewController.view.translatesAutoresizingMaskIntoConstraints = false
-                addChildViewController(mainViewController)
-                view.insertSubview(mainViewController.view, atIndex: 0)
-                view.addConstraints(
-                    NSLayoutConstraint.constraintsWithVisualFormat(
-                        "V:|-0-[mainView]-0-|",
-                        options: [],
-                        metrics: nil,
-                        views: viewDictionary
-                    )
+            guard let mainViewController = mainViewController else { return }
+            let viewDictionary      = ["mainView" : mainViewController.view]
+            mainViewController.view.translatesAutoresizingMaskIntoConstraints = false
+            addChildViewController(mainViewController)
+            view.insertSubview(mainViewController.view, atIndex: 0)
+            view.addConstraints(
+                NSLayoutConstraint.constraintsWithVisualFormat(
+                    "V:|-0-[mainView]-0-|",
+                    options: [],
+                    metrics: nil,
+                    views: viewDictionary
                 )
-                view.addConstraints(
-                    NSLayoutConstraint.constraintsWithVisualFormat(
-                        "H:|-0-[mainView]-0-|",
-                        options: [],
-                        metrics: nil,
-                        views: viewDictionary
-                    )
+            )
+            view.addConstraints(
+                NSLayoutConstraint.constraintsWithVisualFormat(
+                    "H:|-0-[mainView]-0-|",
+                    options: [],
+                    metrics: nil,
+                    views: viewDictionary
                 )
-                mainViewController.didMoveToParentViewController(self)
-            }
+            )
+            mainViewController.didMoveToParentViewController(self)
         }
     }
     

    }
    
    private let _kContainerViewMaxAlpha  : CGFloat        = 0.2
    private let _kDrawerAnimationDuration: NSTimeInterval = 0.25
    
    /**************************************************************************/
    // MARK: - Properties
    /**************************************************************************/
    
    @IBInspectable var mainSegueIdentifier  : String?
    @IBInspectable var drawerSegueIdentifier: String?
    
    private var _drawerConstraint : NSLayoutConstraint!
    
    private var _panStartLocation = CGPointZero
    

        return gesture
    }()
    
    public weak var delegate: KYDrawerControllerDelegate?
    
    public var drawerDirection: DrawerDirection = .Left {
        didSet {
            switch drawerDirection {
            case .Left:  screenEdgePanGesture.edges = .Left
            case .Right: screenEdgePanGesture.edges = .Right
            }
            let tmp = drawerViewController
            drawerViewController = tmp
        }
    }
    
    public var drawerState: DrawerState {
        get { return _containerView.hidden ? .Closed : .Opened }
        set { setDrawerState(drawerState, animated: false) }
    }
    
    @IBInspectable public var drawerWidth: CGFloat = 280 {
        didSet { _drawerWidthConstraint?.constant = drawerWidth }
    }
    
    public var mainViewController: UIViewController! {
        didSet {
