refactor edit method