Passes, but this cannot possibly be idiomatic Clojure
Cleaned up the internal function a bit