Fixed problem with the update function