off-by-one fix