index logic