genetic working but slow -- refactoring needed