use iterator instead of loading all docs into memory