Fix bug of infinite recursive goal expansion