tweak algorithm