Fixed a thrown indexrange exception