Begun a more functional implementation.