Modified recursion functions that would allow it to use tail recursion