finish refactor codes in add & edit work