Refactored get_best_group