fixed add and edit functionality