     (precondition-context [s] precond-var-set)
   hierarchy/HighLevelAction
     (immediate-refinements- [s]
-      (if (every? #(satisfied? % s) precond-hlas) (do (println "gREED!") [[action]])
-        (let [var-actives (active-var-set this)
-              var-leaves  (leaf-var-set this)
-              var-options (clojure.set/difference var-leaves var-actives)]
-          (if (empty? var-options)
-              (println "Dead end!")
-            (for [[prefix remaining]
-                  (do-refinement this s (util/first-maximal-element (:var-levels hierarchy) var-options)
-                                 var-actives var-leaves)]
-              (if remaining (concat prefix [remaining]) prefix))))))
+      (let [var-leaves  (leaf-var-set this)]
+       (if (needs-expand? this)
+         (let [[prefix next] (expand this var-leaves)]
+           (if next (conj prefix next) prefix))
+         (let [var-actives (active-var-set this)
+               var-options (clojure.set/difference var-leaves var-actives)]
+           (if (empty? var-options)
+             (println "Dead end!")
+             (select-leaf this s (util/first-maximal-element (:var-levels hierarchy) var-options) var-actives))))))
     (cycle-level-           [s] nil))
 
 (defn- make-action-hla [hierarchy action]

    (greedy-select? [s v av] 
      (or (every? #(and (satisfied? % s) (or (active? %) (not (av (:var %))))) precond-hlas)
          (some #(greedy-select? % s v av) (util/make-safe (seq (filter #(contains? (leaf-var-set %) v) precond-hlas))))))
    (select-leaf    [s v av lv]
      (let [possible-vals  (filter #(contains? (leaf-var-set (precond-hlas %)) v) (range (count precond-hlas)))
            [deep shallow] (util/separate (comp active? precond-hlas) possible-vals)
            val-options    (or (and (:greedy-optimization? hierarchy) 

  SDH-HLA
    (active-var-set  []  (leaf-var-set inactive-leaf))
    (leaf-var-set    []  (active-var-set inactive-leaf))
    (needs-expand?   []  (not (satisfied? this :dummy)))
    (expand          [lv] 
      (let [{:keys [hierarchy var dst-val dtg]} inactive-leaf]               
       (cond (empty? (clojure.set/intersection lv ((:interfering-set hierarchy) var)))
               [[[inactive-leaf] (advance-active-leaf-precond-hla this dst-val)]]
             (= cur-val dst-val)
