Guard against array index out of bounds