index out of bound fixed