fixed infinite recursion bug