improved update code.