fixed nonlocal detection