functions refactored in more idiomatic clojuric way