replaced strings with defs and added more iteration to the documents namespace