 extension SearchViewController: UITableViewDelegate {
     func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
         var url: NSURL?
-        if indexPath.row < searchSuggestions.count {
-            let suggestion = searchSuggestions[indexPath.row]
-
-            // Assume that only the default search engine can provide search suggestions.
-            url = searchEngines?.defaultEngine.searchURLForQuery(suggestion)
-        } else {
-            let engine = sortedEngines[indexPath.row - searchSuggestions.count]
-            url = engine.searchURLForQuery(searchQuery)
+        if let currentSection = SearchListSection(rawValue: indexPath.section) {
+            switch currentSection {
+            case .SuggestedSites:
+                let suggestion = searchSuggestions[indexPath.row]
+
+                // Assume that only the default search engine can provide search suggestions.
+                url = searchEngines?.defaultEngine.searchURLForQuery(suggestion)
+            case .BookmarksAndHistory:
+                if var hasHistory = history {
+                    if let site = hasHistory[indexPath.row] as? Site {
+                        url = NSURL(string: site.url)
+                    }
+                }
+            case .Search:
+                let engine = sortedEngines[indexPath.row - searchSuggestions.count]
+                url = engine.searchURLForQuery(searchQuery)
+            }
         }
 
         if let url = url {

    var searchQuery: String = "" {
        didSet {
            querySuggestClient()
            
            profile.history.get(searchQuery, options: nil, complete: { (data: Cursor) -> Void in
                if data.status != .Success {
                    println("Err: \(data.statusMessage)")
                } else {
                    self.history = data
                }
            })

            // Reload the tableView to show the updated text in each engine.
            tableView.reloadData()
        }

    }
    
    func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
        return SearchListSection(rawValue: section)?.description
    }
    
    func numberOfSectionsInTableView(tableView: UITableView) -> Int {
