update and optimization