Refactoring genetic algorithm