first working version of genetic algorithm