Add to visited when added to the queue