refactor add and edit actions