index beyond bounds fix