refactor errors on save document