Separated part of print_queue into new function