Index out of bounds crash fixed