Fixed Index out of bounds error