refactor delete and edit