improves index logic