add priority, re construct the data. need more tests and debug