Working-ish version
Working version
Seems more functional now
repl working