Fixed missing tail recursion problem