Fixed recursion bug