Index: /branches/eam_branches/ipp-pstamp-20260421/ippTools/src/bgtool.c
===================================================================
--- /branches/eam_branches/ipp-pstamp-20260421/ippTools/src/bgtool.c	(revision 43032)
+++ /branches/eam_branches/ipp-pstamp-20260421/ippTools/src/bgtool.c	(revision 43033)
@@ -67,4 +67,31 @@
 
 // Tables to import/export
+/* ChatGPT suggested fix */
+typedef struct {
+    const char *name;
+    void *(*parse)(psMetadata *);
+    bool (*insert)(psDB *, void *);
+} tableData;
+static const tableData chipTables[] = {
+    { "chipBackgroundRun",
+      (void *(*)(psMetadata *))  chipBackgroundRunObjectFromMetadata,
+      (bool (*)(psDB *, void *)) chipBackgroundRunInsertObject },
+    { "chipBackgroundImfile",
+      (void *(*)(psMetadata *))  chipBackgroundImfileObjectFromMetadata,
+      (bool (*)(psDB *, void *)) chipBackgroundImfileInsertObject },
+    { NULL, NULL, NULL }
+};
+static const tableData warpTables[] = {
+    { "warpBackgroundRun",
+      (void *(*)(psMetadata *))  warpBackgroundRunObjectFromMetadata,
+      (bool (*)(psDB *, void *)) warpBackgroundRunInsertObject },
+    { "warpBackgroundSkyfile",
+      (void *(*)(psMetadata *))  warpBackgroundSkyfileObjectFromMetadata,
+      (bool (*)(psDB *, void *)) warpBackgroundSkyfileInsertObject },
+    { NULL, NULL, NULL }
+};
+
+
+/* old version
 typedef struct {
     const char *name;                   // Table name
@@ -82,5 +109,5 @@
     { NULL, NULL, NULL }
 };
-
+*/
 
 # define MODECASE(caseName, func) \
@@ -255,7 +282,12 @@
         psAssert(item, "%s not in input", name);
         psAssert(item->type == PS_DATA_METADATA_MULTI, "%s not MULTI type", name);
+
         psAssert(psListLength(item->data.list) == 1, "%s has multiple entries", name);
+
         psMetadataItem *entry = psListGet(item->data.list, PS_LIST_HEAD); // Entry of interest
-        void *data = tables[i].parse(entry);                             // Parsed entry
+	assert (entry);
+	assert (entry->type == PS_DATA_METADATA);
+
+        void *data = tables[i].parse(entry->data.md);                             // Parsed entry
         if (!data) {
             psError(PXTOOLS_ERR_CONFIG, false, "Unable to parse entry %s", name);
@@ -263,5 +295,5 @@
             return false;
         }
-        if (!tables[0].insert(config->dbh, data)) {
+        if (!tables[i].insert(config->dbh, data)) {
             psError(psErrorCodeLast(), false, "Unable to insert entry %s", name);
             psFree(input);
