Move out saveDocument