refactoring update method