Off-by one bug fix