new algrothm to calulate priority, not done yet!