consider the weighting when tracing the best path