cleaned up main function, still debugging recursion