Create detect_loop