small typo and fixing index logic