prevent potential index out of bounds