Refactoring code for Update Button Click Action