diff --git a/aql/convertQuery.go b/aql/convertQuery.go
index 87d4a01221d57db6b34cc4b7f2dcdeb9e47bf94f..bc15ba79fec8dcc1ee18f6b4d4a915cd9ed6fab0 100644
--- a/aql/convertQuery.go
+++ b/aql/convertQuery.go
@@ -96,12 +96,20 @@ func createQuery(JSONQuery *entity.IncomingQueryJSON) *string {
 	}
 
 	// Include all types that are not yet included
+	first := true
 	for k := range allTypes {
 		if !includedTypes[k] {
-			ret += fmt.Sprintf("WITH %v\n", k)
-
+			if first {
+				ret += fmt.Sprintf("WITH %v", k)
+				first = false
+			} else {
+				ret += fmt.Sprintf(", %v", k)
+			}
 		}
 	}
+	if !first {
+		ret += "\n"
+	}
 
 	for i, relation := range JSONQuery.Relations {
 
diff --git a/aql/convertQuery_test.go b/aql/convertQuery_test.go
index 65c891864dc52c895fc3bb152e8672a7d3ecb515..f083a12123332994a623938178fdd1c973e02887 100644
--- a/aql/convertQuery_test.go
+++ b/aql/convertQuery_test.go
@@ -1053,6 +1053,90 @@ func TestNoRelationsField(t *testing.T) {
 	assert.Equal(t, correctConvertedResult, cleanedResult)
 }
 
+/*
+Tests a query with double WITH
+	t: *testing.T, makes go recognise this as a test
+*/
+func TestDoubleWITH(t *testing.T) {
+	// Setup for test
+	// Create query conversion service
+	service := NewService()
+
+	query := []byte(`{
+        "databaseName": "test",
+        "return": {
+          "entities": [
+            0,
+            1,
+            2,
+            3
+          ],
+          "relations": [
+            0,
+            1
+          ]
+        },
+        "entities": [
+          {
+            "type": "kamerleden",
+            "constraints": []
+          },
+          {
+            "type": "partijen",
+            "constraints": []
+          }
+          ,
+          {
+            "type": "kamerleden",
+            "constraints": []
+          },
+          {
+            "type": "commissies",
+            "constraints": []
+          }
+        ],
+        "relations": [
+          {
+            "type": "lid_van",
+            "depth": {
+              "min": 1,
+              "max": 1
+            },
+            "entityFrom": 0,
+            "entityTo": 1,
+            "constraints": []
+          },
+          {
+            "type": "onderdeel_van",
+            "depth": {
+              "min": 1,
+              "max": 1
+            },
+            "entityFrom": 2,
+            "entityTo": 3,
+            "constraints": []
+          }
+        ],
+        "limit": 5000,
+        "modifiers": []
+      }`)
+
+	// Unmarshall the incoming message into an IncomingJSONQuery object
+	var JSONQuery entity.IncomingQueryJSON
+	json.Unmarshal(query, &JSONQuery)
+
+	convertedResult, err := service.ConvertQuery(&JSONQuery)
+
+	// Assert that there is no error
+	assert.NoError(t, err)
+
+	// Assert that the result and the expected result are the same
+	correctConvertedResult := "WITH partijen, commissiesLET n0 = (FOR x IN kamerleden RETURN x)LET r0 = (FOR x IN n0 FOR v, e, p IN 1..1 OUTBOUND x lid_van OPTIONS { uniqueEdges: \"path\" }LIMIT 5000 RETURN DISTINCT p )LET n2 = (FOR x IN kamerleden RETURN x)LET r1 = (FOR x IN n2 FOR v, e, p IN 1..1 OUTBOUND x onderdeel_van OPTIONS { uniqueEdges: \"path\" }LIMIT 5000 RETURN DISTINCT p )LET nodes = first(RETURN UNION_DISTINCT(flatten(r0[**].vertices), flatten(r1[**].vertices), [],[]))LET edges = first(RETURN UNION_DISTINCT(flatten(r0[**].edges), flatten(r1[**].edges), [],[]))RETURN {\"vertices\":nodes, \"edges\":edges }"
+	cleanedResult := strings.ReplaceAll(*convertedResult, "\n", "")
+	cleanedResult = strings.ReplaceAll(cleanedResult, "\t", "")
+	assert.Equal(t, correctConvertedResult, cleanedResult)
+}
+
 /*
 Tests an entity with a lower than -1 in a relation
 	t: *testing.T, makes go recognise this as a test
diff --git a/aql/debug.test b/aql/debug.test
new file mode 100644
index 0000000000000000000000000000000000000000..934cd9a89adf48e864e89ee0528ad2681abfaa01
Binary files /dev/null and b/aql/debug.test differ
diff --git a/main/main.go b/main/main.go
index b2c863a8436360e1a0d2e0f4e185c4a83d5b3080..204395ac15bd59e116505e1e9185e193bee4f0f0 100644
--- a/main/main.go
+++ b/main/main.go
@@ -9,7 +9,7 @@ import (
 	"encoding/json"
 	"log"
 
-	"git.science.uu.nl/datastrophe/query-conversion/cypher"
+	"git.science.uu.nl/datastrophe/query-conversion/aql"
 	"git.science.uu.nl/datastrophe/query-conversion/entity"
 )
 
@@ -17,29 +17,66 @@ import (
 The main function that calls the appropriate functions
 */
 func main() {
-	queryservice := cypher.NewService()
+	queryservice := aql.NewService()
 
 	js := []byte(`{
-		"return": {
-			"entities": [
-				0
-			]
-		},
-		"entities": [
-			{
-				"type": "airports",
-				"constraints": [
-					{
-						"attribute": "city",
-						"value": "San Francisco",
-						"dataType": "string",
-						"matchType": "exact"
-					}
-				]
-			}
-		],
-		"limit": 5000
-	}`)
+        "databaseName": "test",
+        "return": {
+          "entities": [
+            0,
+            1,
+            2,
+            3
+          ],
+          "relations": [
+            0,
+            1
+          ]
+        },
+        "entities": [
+          {
+            "type": "kamerleden",
+            "constraints": []
+          },
+          {
+            "type": "partijen",
+            "constraints": []
+          }
+          ,
+          {
+            "type": "kamerleden",
+            "constraints": []
+          },
+          {
+            "type": "commissies",
+            "constraints": []
+          }
+        ],
+        "relations": [
+          {
+            "type": "lid_van",
+            "depth": {
+              "min": 1,
+              "max": 1
+            },
+            "entityFrom": 0,
+            "entityTo": 1,
+            "constraints": []
+          },
+          {
+            "type": "onderdeel_van",
+            "depth": {
+              "min": 1,
+              "max": 1
+            },
+            "entityFrom": 2,
+            "entityTo": 3,
+            "constraints": []
+          }
+        ],
+        "limit": 5000,
+        "modifiers": []
+      }`)
 
 	var inc entity.IncomingQueryJSON
 	json.Unmarshal(js, &inc)