updateing the update function

adding the logic to the update function