moving functions around to clean up some files