clean codes for add and edit view behaviors