diff --git a/data-discovery/src/main/java/vlkb/output/XmlSerializer.java b/data-discovery/src/main/java/vlkb/output/XmlSerializer.java
index 5bda5b38bf96d3e1d0a3ff002abd49d25b1e2c6d..2300f276ef6d833085ac91ad2709d514f13da799 100644
--- a/data-discovery/src/main/java/vlkb/output/XmlSerializer.java
+++ b/data-discovery/src/main/java/vlkb/output/XmlSerializer.java
@@ -148,92 +148,68 @@ final class XmlSerializer
 
       out.write( "<VOTABLE version='1.1'>" );
       out.write( "<DESCRIPTION> " + searchOutputData.versionString + 
-             " SUBSURVCOUNT: " + searchOutputData.subsurveyArr.length + " </DESCRIPTION>" );
+             " subsurvey count: " + searchOutputData.subsurveyArr.length + " </DESCRIPTION>" );
 
       if((searchOutputData.subsurveyArr != null) && (searchOutputData.subsurveyArr.length > 0))
       {
+         Subsurvey[] subsurv = searchOutputData.subsurveyArr;
+
          // assumes ORDERED subsurveyArray: by surveyname
 
          List<StarTable> tableList = new ArrayList();
-         String prevSurveyname = searchOutputData.subsurveyArr[0].surveyname.trim();
-         for(Subsurvey subsurvey : searchOutputData.subsurveyArr)
+         String prevSurveyname;// = subsurv[0].surveyname.trim();
+         int ix = 0;
+
+         do
          {
+            prevSurveyname = subsurv[ix].surveyname.trim();
 
-            if(prevSurveyname.equals(subsurvey.surveyname.trim()))
-            {
-               StarTable table = makeSubsurveyTable( subsurvey );
-               tableList.add(table);
-            }
-            else
+            do
             {
-               out.write( "<RESOURCE>" );
-               out.write( "<DESCRIPTION> " + prevSurveyname + " </DESCRIPTION>" );
-
-               /* PLACEHOLDER FOR RESOURCE PARAM
-
-                  table.setParameter(new DescribedValue(
-                  new DefaultValueInfo("subsurveyCount",Integer.class,
-                  "Count of subsurveys with found datacube(s)" ),
-                  subsurveyArr.length ) );
-
-                  table.setParameter(new DescribedValue(
-                  new DefaultValueInfo( "survey",  String.class,
-                  "Survey name" ),
-                  subsurvey.surveyname ) );
-
-*/
-
-               StarTable[] tables = tableList.toArray(new StarTable[0]);
-               for ( int i = 0; i < tables.length; i++ )
-               {
-                  VOSerializer.makeSerializer( DataFormat.TABLEDATA, tables[i] ).writeInlineTableElement( out );
-               }
-               tableList.clear();
-
-               out.write( "</RESOURCE>" );
-
-               prevSurveyname = subsurvey.surveyname.trim();
-               StarTable table = makeSubsurveyTable( subsurvey );
+               StarTable table = makeSubsurveyTable( subsurv[ix] );
                tableList.add(table);
+               ix++;
             }
+            while((ix < subsurv.length) && prevSurveyname.equals(subsurv[ix].surveyname.trim()));
 
+            StarTable[] tables = tableList.toArray(new StarTable[0]);
+            writeResourceSurvey(out, prevSurveyname, tables);
+            tableList.clear();
          }
+         while(ix < subsurv.length);
 
-         if(!tableList.isEmpty())
-         {
-            out.write( "<RESOURCE>" );
-            out.write( "<DESCRIPTION> " + prevSurveyname + " </DESCRIPTION>" );
-
-            /* PLACEHOLDER FOR RESOURCE PARAM
+      }
+      out.write( "</VOTABLE>" );
+      out.flush();
+   }
 
-               table.setParameter(new DescribedValue(
-               new DefaultValueInfo("subsurveyCount",Integer.class,
-               "Count of subsurveys with found datacube(s)" ),
-               subsurveyArr.length ) );
+   private static void writeResourceSurvey(BufferedWriter out, String description, StarTable[] tables)
+         throws IOException
+      {
+         out.write( "<RESOURCE>" );
+         out.write( "<DESCRIPTION> " + description + " </DESCRIPTION>" );
 
-               table.setParameter(new DescribedValue(
-               new DefaultValueInfo( "survey",  String.class,
-               "Survey name" ),
-               subsurvey.surveyname ) );
+         /* PLACEHOLDER FOR RESOURCE PARAM
 
-*/
+            table.setParameter(new DescribedValue(
+            new DefaultValueInfo("subsurveyCount",Integer.class,
+            "Count of subsurveys with found datacube(s)" ),
+            subsurveyArr.length ) );
 
-            StarTable[] tables = tableList.toArray(new StarTable[0]);
-            for ( int i = 0; i < tables.length; i++ )
-            {
-               VOSerializer.makeSerializer( DataFormat.TABLEDATA, tables[i] ).writeInlineTableElement( out );
-            }
-            tableList.clear();
+            table.setParameter(new DescribedValue(
+            new DefaultValueInfo( "survey",  String.class,
+            "Survey name" ),
+            subsurvey.surveyname ) );
 
-            out.write( "</RESOURCE>" );
+*/
+         for ( int i = 0; i < tables.length; i++ )
+         {
+            VOSerializer.makeSerializer( DataFormat.TABLEDATA, tables[i] ).writeInlineTableElement( out );
          }
 
+         out.write( "</RESOURCE>" );
       }
 
-      out.write( "</VOTABLE>" );
-      out.flush();
-   }
-
 
 
    private static StarTable makeSubsurveyTable(Subsurvey subsurvey)