update index algorithm