diff --git a/GUI/View/Instrument/DetectorEditor.cpp b/GUI/View/Instrument/DetectorEditor.cpp
index c6ec269133bbc19080dc3258430a0eafeedeec7c..2336ef78c6a4d3e27e13bc88b8d7305704f06fef 100644
--- a/GUI/View/Instrument/DetectorEditor.cpp
+++ b/GUI/View/Instrument/DetectorEditor.cpp
@@ -54,10 +54,7 @@ DetectorEditor::DetectorEditor(QWidget* parent, GISASInstrumentItem* instrItem)
 
     auto* formLayout = new QFormLayout(this);
 
-    auto* collapser = GroupBoxCollapser::installIntoGroupBox(this);
-    collapser->setExpanded(instrItem->expandDetector);
-    connect(collapser, &GroupBoxCollapser::toggled, this,
-            [instrItem](bool b) { instrItem->expandDetector = b; });
+    GroupBoxCollapser::installIntoGroupBox2(this, instrItem->expandDetector);
 
     DetectorItem* detectorItem = instrItem->detectorItem();
     ASSERT(detectorItem);
diff --git a/GUI/View/Widget/GroupBoxes.cpp b/GUI/View/Widget/GroupBoxes.cpp
index ef8e966adb0a880b45c4b3a813ff49fce8f843bc..3c2a676bd38a8dde5877488a6888a93c0d76fd4b 100644
--- a/GUI/View/Widget/GroupBoxes.cpp
+++ b/GUI/View/Widget/GroupBoxes.cpp
@@ -64,6 +64,14 @@ GroupBoxCollapser* GroupBoxCollapser::installIntoGroupBox(QGroupBox* groupBox, b
     return p;
 }
 
+GroupBoxCollapser* GroupBoxCollapser::installIntoGroupBox2(QGroupBox* groupBox, bool& expanded)
+{
+    auto* result = new GroupBoxCollapser(groupBox);
+    result->setExpanded(expanded);
+    connect(result, &GroupBoxCollapser::toggled, [&expanded](bool b) { expanded = b; });
+    return result;
+}
+
 GroupBoxCollapser* GroupBoxCollapser::findInstalledCollapser(QGroupBox* groupBox)
 {
     if (groupBox == nullptr)
diff --git a/GUI/View/Widget/GroupBoxes.h b/GUI/View/Widget/GroupBoxes.h
index bd4dd2b9b907e8376dad321fe652837e1928d69d..dd0e0a9c084cce8bc28b2a55a78033c5765dd297 100644
--- a/GUI/View/Widget/GroupBoxes.h
+++ b/GUI/View/Widget/GroupBoxes.h
@@ -43,6 +43,7 @@ class GroupBoxCollapser : public QObject {
     Q_OBJECT
 public:
     static GroupBoxCollapser* installIntoGroupBox(QGroupBox* groupBox, bool expanded = true);
+    static GroupBoxCollapser* installIntoGroupBox2(QGroupBox* groupBox, bool& expanded);
     static GroupBoxCollapser* findInstalledCollapser(QGroupBox* groupBox);
 
     //! Set the title of the group box. Do not use the method groupBox->setTitle() any more once the