use priority to choose next node