common function for best segment choice