Added some proper Clojure code that mimics the original Java code.