fixed to return a flat sequence of documents; small refactoring