update index logic