fix for part 1 - off-by-one error