fix beyond bounds of array