recalculate priorities code commented