rewrote inference with pure clojure