When is detention illegal?