     public func dismissModal(animationDuration : NSTimeInterval) {
         let t = CGAffineTransformScale(CGAffineTransformIdentity, 1, 1)
         UIView.animateWithDuration(animationDuration, delay: 0, options: UIViewAnimationOptions.CurveEaseOut, animations: {
-            self.jOverlay.removeFromSuperview()
-            self.jOverlay = nil
+            
+            }, completion: nil)
+        UIView.animateWithDuration(animationDuration, delay: 0, options: UIViewAnimationOptions.CurveEaseOut, animations: {
             self.jModal.view.userInteractionEnabled = false
             self.jModal.view.frame = self.jModalStartingRect.rect
             self.view.transform = t
+            self.jOverlay.backgroundColor = UIColor.clearColor()
             self.view.layoutIfNeeded()
             }, completion: { (_) in
+                self.jOverlay.layoutIfNeeded()
+                self.jOverlay.removeFromSuperview()
+                self.jOverlay = nil
                 self.jModal.view.removeFromSuperview()
                 self.jModal = nil
                 self.view.toggleSubviewsUserInteractionEnabled(true)

        let (startingRect, endingRect) = getTransitionCGRectsForTransitionStyle(self, modalViewController: modalViewController, transitionStyle: transitionStyle)
        jModalStartingRect = JRect(rect: startingRect)
        jModalEndingRect = JRect(rect: endingRect)
        addOverlay(dismissAnimationDuration: animationDuration)
        modalViewController.view.frame = startingRect
        self.view.clipsToBounds = false
        let window = UIApplication.sharedApplication().keyWindow
        window?.addSubview(modalViewController.view)
        let t = CGAffineTransformScale(CGAffineTransformIdentity, 0.93, 0.93)
        UIView.animateWithDuration(animationDuration, delay: 0, options: UIViewAnimationOptions.CurveEaseOut, animations: {
            modalViewController.view.userInteractionEnabled = true
            modalViewController.view.frame = endingRect
            self.view.transform = t

        
        self.view.toggleSubviewsUserInteractionEnabled(false)
        jOverlay = UIView(frame: self.view.frame)
        jOverlay.backgroundColor = UIColor.clearColor()
        jOverlay.userInteractionEnabled = true
        jDismissAnimationDuration = dismissAnimationDuration
        let tap = UITapGestureRecognizer(target: self, action: #selector(dismissModalByOverlay))
        jOverlay.addGestureRecognizer(tap)
        let window = UIApplication.sharedApplication().keyWindow
        window?.addSubview(jOverlay)
//        self.view.addSubview(jOverlay)
    }
    
    public func dismissModalByOverlay(recognizer : UITapGestureRecognizer) {
