Now works properly when the queue is empty