         }
         
         foregroundView.alpha = 0
-        foregroundView.foldingAnimation(animationInfo.last!.type,
+        foregroundView.foldingAnimation(kCAMediaTimingFunctionEaseOut,
                                         from: CGFloat(-M_PI / 2),
                                         to: 0,
-                                        duration: animationInfo.last!.duration,
+                                        duration: durations.last!,
                                         delay:delay,
                                         hidden:false)
         

    
    func openAnimation() {
        
        let animationInfo:[(type: String, duration: NSTimeInterval)] = [
                                                                 (kCAMediaTimingFunctionEaseIn, 0.165), // folding open
                                                                 (kCAMediaTimingFunctionEaseOut, 0.165),
            
                                                                 (kCAMediaTimingFunctionEaseIn, 0.13),
                                                                 (kCAMediaTimingFunctionEaseOut, 0.13),
            
                                                                 (kCAMediaTimingFunctionEaseIn, 0.13),
                                                                 (kCAMediaTimingFunctionEaseOut, 0.13),
                                                                ]
        
        var delay: NSTimeInterval = 0
        foregroundView.foldingAnimation(animationInfo[0].type, from: 0, to: CGFloat(-M_PI / 2), duration: animationInfo[0].duration, delay:delay, hidden: true)
        
        let firstItemView = containerView.subviews.filter{$0.tag == 0}.first
        firstItemView!.layer.masksToBounds = true
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, Int64(animationInfo[0].duration * Double(NSEC_PER_SEC))), dispatch_get_main_queue()) { () -> Void in
            firstItemView!.layer.masksToBounds = false
        }
        

                let rotatedView: RotatedView = itemView as! RotatedView
                
                if index - 1 > 0 {
                    rotatedView.backView?.foldingAnimation(kCAMediaTimingFunctionEaseOut,
                        from: CGFloat(-M_PI / 2),
                        to: 0,
                        duration: durations[index-1],
                        delay: delay,
                        hidden: false)
                    delay += durations[index-1]
                }

                if index < durations.count {
                    rotatedView.foldingAnimation(kCAMediaTimingFunctionEaseIn,
                                                    from:0,
                                                    to: CGFloat(M_PI / 2),
                                                    duration: durations[index],
                                                    delay:delay,
                                                    hidden:true)
                    delay += durations[index]
                }
                
                index += 2
