Array Index out of bounds fix