Added a functional version.
shifted some names around
Testing out the functional version.