   
   func createAnimationView() {
     
-    let anAnimationView = UIView(frame: containerView.frame)
-    anAnimationView.layer.cornerRadius = foregroundView.layer.cornerRadius
-    anAnimationView.backgroundColor = .clear
-    anAnimationView.translatesAutoresizingMaskIntoConstraints = false
-    self.contentView.addSubview(anAnimationView)
+    animationView = UIView(frame: containerView.frame)
+    animationView?.layer.cornerRadius = foregroundView.layer.cornerRadius
+    animationView?.backgroundColor = .clear
+    animationView?.translatesAutoresizingMaskIntoConstraints = false
+    animationView?.alpha = 0
+    
+    guard let animationView = self.animationView else { return }
+
+    self.contentView.addSubview(animationView)
     
     // copy constraints from containerView
     var newConstraints = [NSLayoutConstraint]()
     for constraint in self.contentView.constraints {
       if let item = constraint.firstItem as? UIView , item == containerView {
-        let newConstraint = NSLayoutConstraint( item: anAnimationView, attribute: constraint.firstAttribute,
+        let newConstraint = NSLayoutConstraint( item: animationView, attribute: constraint.firstAttribute,
           relatedBy: constraint.relation, toItem: constraint.secondItem, attribute: constraint.secondAttribute,
           multiplier: constraint.multiplier, constant: constraint.constant)
         
         newConstraints.append(newConstraint)
       } else if let item: UIView = constraint.secondItem as? UIView , item == containerView {
         let newConstraint = NSLayoutConstraint(item: constraint.firstItem, attribute: constraint.firstAttribute,
-          relatedBy: constraint.relation, toItem: anAnimationView, attribute: constraint.secondAttribute,
+          relatedBy: constraint.relation, toItem: animationView, attribute: constraint.secondAttribute,
           multiplier: constraint.multiplier, constant: constraint.constant)
         
         newConstraints.append(newConstraint)

    
    for constraint in containerView.constraints { // added height constraint
      if constraint.firstAttribute == .height {
        let newConstraint = NSLayoutConstraint(item: anAnimationView, attribute: constraint.firstAttribute,
          relatedBy: constraint.relation, toItem: nil, attribute: constraint.secondAttribute,
          multiplier: constraint.multiplier, constant: constraint.constant)
        
        anAnimationView.addConstraint(newConstraint)
      }
    }
    animationView = anAnimationView
  }

  

    
    let firstItemView = animationView.subviews.filter{$0.tag == 0}.first
    
    firstItemView?.layer.masksToBounds = true
    DispatchQueue.main.asyncAfter(deadline: .now() + durations[0], execute: {
      firstItemView?.layer.cornerRadius = 0
    })
    
    DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + Double(Int64(delay * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC), execute: {
      self.animationView?.alpha = 0
      self.containerView.alpha  = 1
