Update the document properly