Refactor seed generation code