Extracting value exists in queue to a separate method for readability