Improve the update code