refactor to clojure