    lexicon
    (fn [k vals]
      (mapcat (fn [val]
-               (cond (not (fail? (unify val if-has)))
-                     (do
-                       (log/debug (str val ": matches: if: " if-has " then " unify-with))
-                       (list (unify val unify-with)))
+               (let [result (unifyc val if-has)]
+                 (cond (not (fail? result))
+                       (do
+                         (log/debug (str val ": matches: if: " if-has " then " unify-with))
+                         (list result))
                      true
-                     (list val)))
+                     (list val))))
              vals))))
 
 (defn get-fail-path [map1 map2]

        (merge-with concat lexicon-stage-3 exceptions)]
    lexicon))

(defn unify [ & args]
  "like unify/unify, but unify/copy each argument before unifying."
  (do
    (log/trace (str "(lexfn)unify args: " args))
    (log/trace (str "(lexfn)unify first arg: " (first args)))
    (apply unifyc args)))

(defn cache-serialization [entry]
  "Copying ((unify/copy)ing) lexical entries during generation or parsing is done by serializing and then deserializing. 

   [clojure.set :as set]
   [clojure.tools.logging :as log]
   [clojure.core :as core]
   [clojure.string :as string]
   [babel.pos :refer :all]
   [dag-unify.core :refer :all :exclude (unify)])) ;; exclude unify because we redefine it here using unifyc (copy each arg)

