Fixed the update function.