fix loop detection for multi-vars