update() function optimization