implemented the update function