Updated update function.