     
     func closeButtonDidTap(sender:UIButton) {
 
-        if self.delegate!.respondsToSelector("photoSliderControllerWillDismiss:") {
-            self.delegate!.photoSliderControllerWillDismiss!(self)
+        if (self.delegate?.respondsToSelector("photoSliderControllerWillDismiss:") != nil) {
+            self.delegate?.photoSliderControllerWillDismiss!(self)
         }
         self.dissmissViewControllerAnimated(true)
 

        let screenWidth = UIScreen.mainScreen().bounds.size.width
        var movedHeight = CGFloat(0)
        
        if self.delegate!.respondsToSelector("photoSliderControllerWillDismiss:") {
            self.delegate!.photoSliderControllerWillDismiss!(self)
        }
        
        if up {

    func dissmissViewControllerAnimated(animated:Bool) {
        self.dismissViewControllerAnimated(animated, completion: { () -> Void in
            
        if (self.delegate?.respondsToSelector("photoSliderControllerDidDismiss:") != nil) {
                self.delegate?.photoSliderControllerDidDismiss!(self)
            }
            
        })
