fix off-by-one error in generation predicat