Genetic algorithm refactored