prevent race when incrementing gen