update index logic, working