wip priority queue and cost estimation function