build the document