genetic algorithm refactoring