Finished refuctoring lisp version