Fixing numGen to give a number in the valid range.