updates algorithm