Refactored code and added seed generation