refactor towards idiomatic clojure