fix off-by-one in bounds check

fixes an off-by-one error in an array bounds check