Corrected index out of bound