fixed saving of documents