fixed minor off-by-one bug