fix off-by-one in bounds check