off-by-one bug