refactured edit and update