explain the nested function definition in pqueue