Fix an off-by-one bug