Off-by-one error fix