Refactored DocumentCollection to get rid of for loop