Fix recursion only with case for Document