     
     func tabBarItemClicked(sender: AnyObject) {
         if let tabBar = sender as? TTTabBarItem {
-            self.loadViewController(tabBar)
-        }
-    }
-    
-    func loadViewController(tabBarItem: TTTabBarItem) {
-        if !self.ttTabBar(self, shouldChangeTab: tabBarItem) {
-            return
-        }
-        
-        //if users click on the same tab that is active, return
-        if let tabBar = activeTabBar {
-            if tabBarItem == activeTabBar {
+            self.loadViewControllerFrom(tabBar)
+        }
+    }
+    
+    func loadViewControllerFrom(tabBarItem: TTTabBarItem?) {
+        if let item = tabBarItem {
+            if !self.ttTabBar(self, shouldChangeTab: item) {
                 return
+            }
+            
+            //if users click on the same tab that is active, return
+            if let tabBar = activeTabBar {
+                if item == activeTabBar {
+                    return
+                }
             }
         }
         

            ttTabBar(self, tabDidDisappear: tabBar)
        }
        
        //Change image to the new tabBarItem to selected
        if let image = tabBarItem.selectedImage {
            tabBarItem.setImage(image, forState: UIControlState.Normal)
        }
        
        
        //add VC to detailView
        if let vc = tabBarItem.viewController {
            ttTabBar(self, tabWillAppear: tabBarItem)
            //set active bar
            activeTabBar = tabBarItem
            
            vc.view.frame = self.detailView.bounds
            detailView.addSubview(vc.view)
            self.addChildViewController(vc)
            vc.didMoveToParentViewController(self)
            
            ttTabBar(self, tabDidAppear: tabBarItem)
        }
    }
    
    //MARK: overridable Func

        self.renderButtons()
    }
    
    private func updateBackgroundColor (color: UIColor) {
        contentTabBarView.backgroundColor = color
    }
    
