working genetic algorithm