fix out of range index