Add support for tail recursion