Code refactoring
Mergin document_add and document_edit