diff --git a/testxmlstructure.cxx b/testxmlstructure.cxx
index 54dc9f32be308e2cfe65040285eda0977dd6cbed..6846eb23163b5323b2b783dc6ba4a8d29e9e1548 100644
--- a/testxmlstructure.cxx
+++ b/testxmlstructure.cxx
@@ -16,6 +16,14 @@ void assignToModule(std::vector<uint> barcodes, std::string moduleSN);
 int main() {
   initialize();
   std::vector<uint> barcodes;
+  barcodes.push_back(0);
+  barcodes.push_back(0);
+  barcodes.push_back(0);
+  barcodes.push_back(0);
+  barcodes.push_back(0);
+  barcodes.push_back(0);
+  barcodes.push_back(0);
+  barcodes.push_back(0);
   barcodes.push_back(1309009619);
   barcodes.push_back(1309009602);
   barcodes.push_back(1309009633);
@@ -36,6 +44,10 @@ void initialize() {
 }
 
 void assignToModule(std::vector<uint> barcodes, std::string moduleSN) {
+  if (barcodes.size() != 16) {
+    throw "Vector with barcodes must contain exactly 16 elements!";
+  }
+
   QString buffer;
   QXmlStreamWriter xml ( &buffer );
 
@@ -43,22 +55,15 @@ void assignToModule(std::vector<uint> barcodes, std::string moduleSN) {
   xml.writeStartDocument( QString::fromUtf8( "1.0" ) );
   xml.writeStartElement( QString::fromUtf8( "productiondb" ) ) ;
   xml.writeTextElement("moduleSN",QString::fromStdString(moduleSN));
-  xml.writeEmptyElement("Slot0");
-  xml.writeEmptyElement("Slot1");
-  xml.writeEmptyElement("Slot2");
-  xml.writeEmptyElement("Slot3");
-  xml.writeEmptyElement("Slot4");
-  xml.writeEmptyElement("Slot5");
-  xml.writeEmptyElement("Slot6");
-  xml.writeEmptyElement("Slot7");
-  xml.writeTextElement("Slot8",QString::number(barcodes[0]));
-  xml.writeTextElement("Slot9",QString::number(barcodes[1] ));
-  xml.writeTextElement("SlotA",QString::number(barcodes[2] ));
-  xml.writeTextElement("SlotB",QString::number(barcodes[3] ));
-  xml.writeTextElement("SlotC",QString::number(barcodes[4] ));
-  xml.writeTextElement("SlotD",QString::number(barcodes[5] ));
-  xml.writeTextElement("SlotE",QString::number(barcodes[6] ));
-  xml.writeTextElement("SlotF",QString::number(barcodes[7] ));
+
+  for (size_t i = 0; i < 16; i++) {
+    std::string entryname = std::string("Slot") + std::to_string(i);
+    if (barcodes[i]==0)
+        xml.writeEmptyElement(QString::fromStdString(entryname));
+    else
+        xml.writeTextElement(QString::fromStdString(entryname),QString::number(barcodes[i]));
+  }
+
   xml.writeEndDocument();
 
   std::string xmlRequest = buffer.toStdString();