writing the document