             
         case "getTopSites":
             if let limit = data as? Int {
-                reloadTopSitesWithLimit(limit, callback: callback!)
+                refreshTopSites(limit, callback: callback!)
             }
             
         case "searchHistory":

class JavaScriptBridge {
    weak var delegate: JavaScriptBridgeDelegate?
    var profile: Profile
    
    init(profile: Profile) {
        self.profile = profile
    }
    
    func callJSMethod(methodName: String, parameter: AnyObject?) {

        }
    }
    
    // Mark: Helper methods
    
    private func refreshTopSites(frecencyLimit: Int, callback: String) {
        // Reload right away with whatever is in the cache, then check to see if the cache is invalid. If it's invalid,
        // invalidate the cache and requery. This allows us to always show results right away if they are cached but
        // also load in the up-to-date results asynchronously if needed
        reloadTopSitesWithLimit(frecencyLimit, callback: callback) >>> {
            return self.profile.history.updateTopSitesCacheIfInvalidated() >>== { result in
                return result ? self.reloadTopSitesWithLimit(frecencyLimit, callback: callback) : succeed()
            }
        }
    }
    
    private func reloadTopSitesWithLimit(limit: Int, callback: String) -> Success {
        return self.profile.history.getTopSitesWithLimit(limit).bindQueue(dispatch_get_main_queue()) { result in
            var results = [[String: String]]()
            if let r = result.successValue {
