Started refactoring update code