Extracted update code to a new method.