Refactoring of edit functions