update alogrithm