         buttons.removeAll()
         
         for (index, dataObject) in dataObjects.enumerate() {
-            createButton(dataObject, atIndex: index)
+            let button = createButton(dataObject, atIndex: index)
+            button.selected = button.index == selectedIndex
         }
         
         configureUnderlineWidth()
-        
-        if !(selectedIndex < buttons.count) {
-            fatalError("Invalid selection for buttons: \(selectedIndex)")
-        }
-        let selectedButton = buttons[selectedIndex]
-        selectedButton.selected = true
-    }
-    
-    func createButton(dataObject: TabDataObject, atIndex index: Int) {
+    }
+    
+    func createButton(dataObject: TabDataObject, atIndex index: Int) -> TabButton {
         let button = TabButton(index: index, dataObject: dataObject)
         button.delegate = self
         button.selectedColor = tintColor

        button.titleFont = titleFont
        stackView.addArrangedSubview(button)
        buttons.append(button)
    }
    
    func configureUnderlineWidth() {

    }
    
    func updateTabs() {
        for button in buttons {
            button.selected = button.index == selectedIndex
            button.titleFont = titleFont
