bounds checking fix