fix error with index pointer