modified to take the best score;
optimization needed, though.