          local-dir :local-dir} edb-config
          status (thrift/ready-status :loading? true)
          domain-names (keys domains-info)
-         loaders (p-dofor [[domain info] domains-info
-                           :let [remote-path (get remote-path-map domain)
-                                 loader-state (or state (mk-loader-state
-                                                         {domain (domain/host-shards info)}))]]
+         loaders (p-dofor [[domain info] domains-info]
                           (try (domain/set-domain-status! info status)
-                               (when-let [new-data (use-cache-or-update domain
-                                                                        remote-path
-                                                                        edb-config
-                                                                        loader-state)]  
-                                 (domain/set-domain-data! rw-lock domain info new-data))
+                               (let [remote-path (get remote-path-map domain)
+                                     loader-state (or state (mk-loader-state
+                                                             {domain (domain/host-shards info)}))]
+                                 (when-let [new-data (use-cache-or-update domain
+                                                                          remote-path
+                                                                          edb-config
+                                                                          loader-state)]  
+                                   (domain/set-domain-data! rw-lock domain info new-data)))
                                (domain/set-domain-status! info (thrift/ready-status))
                                (catch Throwable t
                                  (log-error t "Error when loading domain " domain)

    (DomainStore. (local-filesystem)
                  local-path
                  (.getSpec remote-vs))))

(defn use-cache-or-update
  [domain remote-path edb-config state]

        (let [{:keys [finished-loaders shard-states]} state]
          (swap! finished-loaders + (count (shard-states domain))))))))

(defn load-and-sync-status!
  "TODO: Only note success for non-failed domains. check thrift status."
  [edb-config rw-lock domains-info & {:keys [state]}]
