created crazy semi-functional version (not semi-functional as in barely working, but as in imperative on the surface, functional on the inside)