                                         grids))]
        grids-w-new-label)))
 
+(defn update-char-vec-in-state! [state* pos-idx new-char-vec]
+  (p ::update-char-vec-in-state!
+     (swap! state* assoc-in [::grid-cells pos-idx] new-char-vec)))
+
 (defn update-grid-cells [state t]
   ;;TODO spec this
   (p ::update-grid-cells
      (let [lambda (get-in state [::properties ::lambda])
            state* (atom state)]
        (doseq [[pos-idx char-vec] (::grid-cells @state*)]
-         (swap! state* assoc-in
-                [::grid-cells pos-idx]
-                (update-char-vec-label
-                  {::char-vec   (update-char-vec-density char-vec t lambda false)
-                   ::properties (::properties state)
-                   ::t          t})))
+         (update-char-vec-in-state!
+           state*
+           pos-idx
+           (update-char-vec-label
+             {::char-vec   (update-char-vec-density char-vec t lambda false)
+              ::properties (::properties state)
+              ::t          t})))
        @state*)))
 
 (defn dense-grids->unique-clusters [state]

  (when (= ::sparse (::label char-vec))
    (let [old-cluster (::cluster char-vec)]
      ;(log-it pos-idx ::sparse-label {:cluster old-cluster})
      (swap! updated-state* assoc-in [::grid-cells pos-idx]
             (assoc char-vec ::cluster "NO_CLASS"))
      (let [new-cluster (cluster->grid-cells old-cluster @updated-state*)]
        ;;step 6
        (when (and

    (when (and (not (= "NO_CLASS" current-cluster))
               (> (cluster->size current-cluster @updated-state*)
                  (cluster->size biggest-neighbor @updated-state*)))
      (update-char-vec-in-state!
        updated-state*
        (first grid-w-biggest-neighbor)
        (assoc
          (second grid-w-biggest-neighbor)
          ::cluster
          current-cluster)))))

(defn adjust-clustering [state t]
  (log-it [state t] ::adjust-clustering [{:t t}])
