Update algorithm