update function finally works