fixed a bug at processDocuments()