index out of range fix