Fixed tail recursion