detect loop doc