Fixed the recursion bug