     }
 
     func SELdidSelectEngine(sender: UIButton) {
-        // The UIButtons are the same cardinality and order as the array of quick search engines
-        for i in 0..<searchEngineScrollViewContent.subviews.count {
-            if let button = searchEngineScrollViewContent.subviews[i] as? UIButton {
-                if button === sender {
-                    //subtract 1 from index to account for magnifying glass accessory
-                    if let url = searchEngines.quickSearchEngines[i-1].searchURLForQuery(searchQuery) {
-                        searchDelegate?.searchViewController(self, didSelectURL: url)
-                    }
-                }
-            }
+        // The UIButtons are the same cardinality and order as the array of quick search engines.
+        // Subtract 1 from index to account for magnifying glass accessory.
+        if let index = searchEngineScrollViewContent.subviews.indexOf(sender),
+           let url = quickSearchEngines[index - 1].searchURLForQuery(searchQuery) {
+            searchDelegate?.searchViewController(self, didSelectURL: url)
         }
     }
 

        searchEngines.shouldShowSearchSuggestionsOptIn = false
        querySuggestClient()
        layoutSuggestionsOptInPrompt()
    }

    func SELdidClickOptInNo() {
        searchEngines.shouldShowSearchSuggestions = false
        searchEngines.shouldShowSearchSuggestionsOptIn = false
        layoutSuggestionsOptInPrompt()
    }

    func keyboardHelper(keyboardHelper: KeyboardHelper, keyboardWillShowWithState state: KeyboardState) {


            layoutSuggestionsOptInPrompt()
        }
    }

    private var quickSearchEngines: [OpenSearchEngine] {
        var engines = searchEngines.quickSearchEngines

        // If we're not showing search suggestions, the default search engine won't be visible
        // at the top of the table. Show it with the others in the bottom search bar.
        if isPrivate || !searchEngines.shouldShowSearchSuggestions {
            engines.insert(searchEngines.defaultEngine, atIndex: 0)
        }

        return engines
    }

    private func layoutSuggestionsOptInPrompt() {
