Selecting the best path