fix problem with empty queue