fix some bugs on find documents with internal/reference