classic off-by-one error