define nest_to helper, fix bug in best_class