refactor and add edit form