diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/MetaCollectionSerializer.java b/src/main/java/de/ids_mannheim/korap/query/serialize/MetaCollectionSerializer.java
index 53c90ab..0482480 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/MetaCollectionSerializer.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/MetaCollectionSerializer.java
@@ -84,8 +84,7 @@
         this.tester = tester();
     }
 
-    //resources must be ordered: 0 without parent, 1 has 0 as parent, etc.
-    // what about extend?! is that also part of the VC meta query?!
+    @Deprecated
     public String serialize(String resource) throws IOException {
         Map metas = new HashMap();
         Map<String, String> pa = getParents(resource);
@@ -97,6 +96,18 @@
         metas.put("meta", parids);
         return mapper.writeValueAsString(metas);
     }
+    //resources must be ordered: 0 without parent, 1 has 0 as parent, etc.
+    public List<Map> serialize(List<String> r_queries) throws IOException {
+        Map metas = new HashMap();
+        List<Map> parids = new ArrayList<>();
+        for (String query : r_queries) {
+            Map re = types.mapify(query);
+            parids.add(re);
+        }
+//        metas.put("meta", parids);
+//        return mapper.writeValueAsString(metas);
+        return parids;
+    }
 
     private Map<String, String> getParents(String id) {
         Map<String, String> cursor = getResource(id);
@@ -106,7 +117,6 @@
         if (cursor.get("parent") != null && !cursor.get("parent").isEmpty())
             parents.putAll(getParents(cursor.get("parent")));
         return parents;
-
     }
 
     //todo: connection to database module!
@@ -136,4 +146,6 @@
         return l;
     }
 
+
+
 }
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/MetaQuerySerializer.java b/src/main/java/de/ids_mannheim/korap/query/serialize/MetaQuerySerializer.java
index 150cb5d..8088ecc 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/MetaQuerySerializer.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/MetaQuerySerializer.java
@@ -67,7 +67,7 @@
     public List serializeQueries(Map<String, String> queries, TYPE type) {
         boolean extend, single = true;
         boolean multypes = queries.keySet().size() > 1;
-        List metavalue;
+        List<Map> metavalue;
         String def_key = null;
         if (queries.size() > 1)
             single = false;
@@ -80,14 +80,14 @@
                 break;
         }
 
-        List value = new ArrayList<>();
-        Map<String, String> dates = new LinkedHashMap<>();
+        List value = new LinkedList();
+        List<String> dates = new LinkedList<>();
         for (String key : queries.keySet()) {
             if (!multypes)
                 def_key = key;
-            if (key.contains("~") | key.contains(">") |
-                    key.contains("<")) {
-                dates.put(key, queries.get(key));
+            if (queries.get(key).contains("~") | queries.get(key).contains(">") |
+                    queries.get(key).contains("<")) {
+                dates.add(queries.get(key));
                 continue;
             }
 
@@ -118,7 +118,7 @@
             if (multypes)
                 term = types.createTerm(key, null, queries.get(key).trim(), null);
             else
-                term = types.createTerm(queries.get(key).trim(), null);
+                term = types.createTerm(def_key, null, queries.get(key).trim(), null);
             value.add(term);
         }
 
@@ -129,14 +129,11 @@
             Map term2 = types.createTerm(proc[2], "korap:date");
             Map group = types.createGroup("between", "pubDate", Arrays.asList(term1, term2));
             value.add(group);
-        }
-
-        if (proc[1] != null) {
+        } else if (proc[1] != null) {
             Map term1 = types.createTerm(proc[1], "korap:date");
             Map group = types.createGroup("since", "pubDate", Arrays.asList(term1));
             value.add(group);
-        }
-        if (proc[2] != null) {
+        } else if (proc[2] != null) {
             Map term1 = types.createTerm(proc[2], "korap:date");
             Map group = types.createGroup("until", "pubDate", Arrays.asList(term1));
             value.add(group);
@@ -145,8 +142,9 @@
 
         for (int i = idx; i < proc.length; i++) {
             if (proc[i] != null) {
-                Map term = types.createTerm("pubDate", null, proc[i], "korap:date");
-                value.add(term);
+                Map term1 = types.createTerm(proc[i], "korap:date");
+                Map group = types.createGroup("until", "pubDate", Arrays.asList(term1));
+                value.add(group);
             }
         }
 
@@ -180,26 +178,31 @@
     }
 
     //fixme: only allows for one until and since entry!!
-    private String[] processDates(Map<String, String> dates) {
+    private String[] processDates(List<String> dates) {
         if (dates.isEmpty())
             return new String[3];
-        boolean until = false, since = false;
-        String[] el = new String[dates.keySet().size() + 3];
+        boolean range = false;
+        String[] el = new String[dates.size() + 3];
         int idx = 3;
-        for (String key : dates.keySet()) {
-            if (key.contains("<")) {
-                since = true;
-                el[1] = types.formatDate(Long.valueOf(dates.get(key)), MetaTypes.YMD);
-            } else if (key.contains(">")) {
-                until = true;
-                el[2] = types.formatDate(Long.valueOf(dates.get(key)), MetaTypes.YMD);
+        for (String value : dates) {
+            if (value.contains("<")) {
+                String[] sp = value.split("<");
+                el[1] = types.formatDate(Long.valueOf(sp[1]), MetaTypes.YMD);
+            } else if (value.contains(">")) {
+                String[] sp = value.split(">");
+                el[2] = types.formatDate(Long.valueOf(sp[1]), MetaTypes.YMD);
+            } else if (value.contains("~")) {
+                range = true;
+                String[] sp = value.split("~");
+                el[1] = types.formatDate(Long.valueOf(sp[0]), MetaTypes.YMD);
+                el[2] = types.formatDate(Long.valueOf(sp[1]), MetaTypes.YMD);
             } else {
-                el[idx] = types.formatDate(Long.valueOf(dates.get(key)), MetaTypes.YMD);
+                el[idx] = types.formatDate(Long.valueOf(value), MetaTypes.YMD);
                 idx++;
             }
 
         }
-        if (since && until)
+        if (range)
             el[0] = "r";
         return el;
     }
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/MetaSerializer.java b/src/main/java/de/ids_mannheim/korap/query/serialize/MetaSerializer.java
new file mode 100644
index 0000000..1ed0737
--- /dev/null
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/MetaSerializer.java
@@ -0,0 +1,42 @@
+package de.ids_mannheim.korap.query.serialize;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author hanl
+ * @date 05/12/2013
+ */
+public class MetaSerializer {
+
+
+    private MetaQuerySerializer qs;
+    private MetaCollectionSerializer cs;
+    private ObjectMapper mapper;
+
+
+    public MetaSerializer() {
+        this.qs = new MetaQuerySerializer();
+        this.cs = new MetaCollectionSerializer();
+        this.mapper = new ObjectMapper();
+    }
+
+    public String serializeMeta(List m_queries) throws JsonProcessingException {
+        Map metas = new HashMap();
+        metas.put("meta", m_queries);
+        return mapper.writeValueAsString(metas);
+    }
+
+    public List<Map> serialzeResources(List<String> r_queries) throws IOException {
+        return cs.serialize(r_queries);
+    }
+
+    public List<Map> serializeQueries(Map<String, String> queries, MetaQuerySerializer.TYPE type) {
+        return qs.serializeQueries(queries, type);
+    }
+}
diff --git a/src/test/java/MetaQuerySerializationTest.java b/src/test/java/MetaQuerySerializationTest.java
index 99fb774..ccd0011 100644
--- a/src/test/java/MetaQuerySerializationTest.java
+++ b/src/test/java/MetaQuerySerializationTest.java
@@ -1,3 +1,6 @@
+import com.fasterxml.jackson.core.JsonGenerationException;
+import com.fasterxml.jackson.databind.JsonMappingException;
+import de.ids_mannheim.korap.query.serialize.JsonGenerator;
 import de.ids_mannheim.korap.query.serialize.MetaCollectionSerializer;
 import de.ids_mannheim.korap.query.serialize.MetaQuerySerializer;
 import org.joda.time.DateTime;
@@ -41,29 +44,29 @@
         Map<String, String> j = new HashMap();
         j.put("textClass", "wissenschaft");
         String s = querySerializer.stringify(j, MetaQuerySerializer.TYPE.FILTER);
-//        System.out.println("value reference test single " + s);
+        System.out.println("------ TEXT SINGLE " + s);
     }
 
     @Test
     public void testResourceMeta() throws IOException {
         String s = collSerializer.serialize("25");
-//        System.out.println(" --- RESULT JSON " + s);
+        System.out.println(" --- RESULT JSON " + s);
     }
 
     @Test
     public void testDates() throws IOException {
         Map<String, String> queries = new LinkedHashMap<>();
-        queries.put("<pubDate", String.valueOf(new DateTime().getMillis()));
-        queries.put(">pubDate", String.valueOf(new DateTime().getMillis() + 2));
+        queries.put("pubDate", String.valueOf(new DateTime().getMillis()) + "~"
+                + String.valueOf(new DateTime().getMillis() + 2));
         queries.put("author", "Goethe");
         String f = querySerializer.stringify(queries, MetaQuerySerializer.TYPE.FILTER);
-//        System.out.println("value : "+ f);
+        System.out.println("value until/since : " + f);
     }
 
     @Test
     public void testUntil() throws IOException {
         Map<String, String> queries = new LinkedHashMap<>();
-        queries.put(">pubDate", String.valueOf(new DateTime().getMillis()));
+        queries.put("pubDate", ">" + String.valueOf(new DateTime().getMillis()));
         queries.put("author", "Hesse");
         String f = querySerializer.stringify(queries, MetaQuerySerializer.TYPE.FILTER);
         System.out.println("value until : " + f);
@@ -72,10 +75,43 @@
     @Test
     public void testSince() throws IOException {
         Map<String, String> queries = new LinkedHashMap<>();
-        queries.put("<pubDate", String.valueOf(new DateTime().getMillis()));
+        queries.put("pubDate", "<" + String.valueOf(new DateTime().getMillis()));
         queries.put("author", "Kafka");
         String f = querySerializer.stringify(queries, MetaQuerySerializer.TYPE.FILTER);
         System.out.println("value since : " + f);
     }
 
+    //@Test
+    public void testGenerator() {
+                   /*
+         * just for testing...
+		 */
+        JsonGenerator jg = new JsonGenerator();
+        int i = 0;
+        String[] queries;
+        queries = new String[]{
+                "shrink({[base=foo]})",
+                "shrink({[base=foo]}[orth=bar])",
+                "shrink(1:[base=Der]{1:[base=Mann]})",
+        };
+
+        for (String q : queries) {
+            i++;
+            try {
+                System.out.println(q);
+                jg.run(q, "poliqarp", System.getProperty("user.home") + "/bsp" + i + ".json");
+                System.out.println();
+            } catch (NullPointerException npe) {
+                npe.printStackTrace();
+                System.out.println("null\n");
+            } catch (JsonGenerationException e) {
+                e.printStackTrace();
+            } catch (JsonMappingException e) {
+                e.printStackTrace();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
 }
