fixed index out of bound exception