Loop detection for NDS