updated the update function