index계산 logic