checking array index out of bound exception