Function saveDocSync