Array out of bounds fix