working evolution algorithm
refactor