Fix the queue logic