 import UIKit
 
 class RAMAnimatedTabBarItem: UITabBarItem {
-
-    @IBOutlet weak var animation: RAMItemAnimation?
-    @IBInspectable var textColor = UIColor.blackColor()
-
-    func playAnimation(icon: UIImageView, textLabel: UILabel){
-        guard let animation = animation else {
-            print("add animation in UITabBarItem")
-            return
-        }
-        animation.playAnimation(icon, textLabel: textLabel)
-    }
-
+    
+    @IBOutlet weak var animation: RAMItemAnimation!
+    @IBInspectable var textColor: UIColor = UIColor.blackColor()
+    
+    func playAnimation(icon: UIImageView, textLabel: UILabel) {
+        
+        assert(animation != nil, "add animation in UITabBarItem")
+        if animation != nil {
+            animation.playAnimation(icon, textLabel: textLabel)
+        }
+    }
+    
     func deselectAnimation(icon: UIImageView, textLabel: UILabel) {
-        animation?.deselectAnimation(icon, textLabel: textLabel, defaultTextColor: textColor)
-    }
-
+        if animation != nil {
+            animation.deselectAnimation(icon, textLabel: textLabel, defaultTextColor: textColor)
+        }
+    }
+    
     func selectedState(icon: UIImageView, textLabel: UILabel) {
-        animation?.selectedState(icon, textLabel: textLabel)
+        if animation != nil {
+            animation.selectedState(icon, textLabel: textLabel)
+        }
     }
 }
 
 class RAMAnimatedTabBarController: UITabBarController {
-
-    var iconsView: [(icon: UIImageView, textLabel: UILabel)] = []
-
-// MARK: life circle
-
+    
+    var iconsView: [(icon: UIImageView, textLabel: UILabel)] = Array()
+    
+    // MARK: life circle
+    
     override func viewDidLoad() {
         super.viewDidLoad()
-
+        
         let containers = createViewContainers()
-
+        
         createCustomIcons(containers)
-    }
-
-// MARK: create methods
-
-    func createCustomIcons(containers : [String: UIView]) {
-
-        if let items = tabBar.items as? [RAMAnimatedTabBarItem] {
-            
-            let itemsCount = items.count as Int - 1
-            
-            for (index, item) in items.enumerate() {
-
+        
+        
+    }
+    
+    // MARK: create methods
+    
+    func createCustomIcons(containers : NSDictionary) {
+        
+        if let _ = tabBar.items {
+            let itemsCount = tabBar.items!.count as Int - 1
+            var index = 0
+            for item in self.tabBar.items as! [RAMAnimatedTabBarItem] {
+                
                 assert(item.image != nil, "add image icon in UITabBarItem")
                 
-                guard let container = containers["container\(itemsCount-index)"] else
-                {
-                    print("No container given")
-                    continue
-                }
-                
+                let container : UIView = containers["container\(itemsCount-index)"] as! UIView
                 container.tag = index
-
+                
                 let icon = UIImageView(image: item.image)
                 icon.translatesAutoresizingMaskIntoConstraints = false
                 icon.tintColor = UIColor.clearColor()
-
+                
                 // text
                 let textLabel = UILabel()
                 textLabel.text = item.title

            multiplier: 1,
            constant: 0)
        container.addConstraint(constX)

        let constY = NSLayoutConstraint(item: view,
            attribute: NSLayoutAttribute.CenterY,
            relatedBy: NSLayoutRelation.Equal,

                textLabel.font = UIFont.systemFontOfSize(10)
                textLabel.textAlignment = NSTextAlignment.Center
                textLabel.translatesAutoresizingMaskIntoConstraints = false
                
                container.addSubview(icon)
                createConstraints(icon, container: container, size: item.image!.size, yOffset: -5)
                
                container.addSubview(textLabel)
                let textLabelWidth = tabBar.frame.size.width / CGFloat(tabBar.items!.count) - 5.0
                createConstraints(textLabel, container: container, size: CGSize(width: textLabelWidth , height: 10), yOffset: 16)
                
                let iconsAndLabels = (icon:icon, textLabel:textLabel)
                iconsView.append(iconsAndLabels)
                
                if 0 == index { // selected first elemet
                    item.selectedState(icon, textLabel: textLabel)
                }
                
                item.image = nil
                item.title = ""
                index++
            }
        }
    }
    
    func createConstraints(view:UIView, container:UIView, size:CGSize, yOffset:CGFloat) {
        
        let constX = NSLayoutConstraint(item: view,
            attribute: NSLayoutAttribute.CenterX,
            relatedBy: NSLayoutRelation.Equal,
