Fix infinite recursion bug