Checking and removing from the queue