Added check for minimum repetition and formatted codes.

Change-Id: Id19e4d844ddb1cf46d69d68bacb5d07a656de5f3
diff --git a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanAlterQueryWrapper.java b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanAlterQueryWrapper.java
index 8fd18cd..9b71cbf 100644
--- a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanAlterQueryWrapper.java
+++ b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanAlterQueryWrapper.java
@@ -48,8 +48,8 @@
         this.alternatives = new ArrayList<>();
         for (String term : terms) {
             this.isNull = false;
-            this.alternatives.add(new SpanSimpleQueryWrapper(new SpanTermQuery(
-                    new Term(this.field, term))));
+            this.alternatives.add(new SpanSimpleQueryWrapper(
+                    new SpanTermQuery(new Term(this.field, term))));
         };
     };
 
diff --git a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanAttributeQueryWrapper.java b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanAttributeQueryWrapper.java
index 0d0fe23..d2941f9 100644
--- a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanAttributeQueryWrapper.java
+++ b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanAttributeQueryWrapper.java
@@ -8,7 +8,7 @@
 
 /**
  * @author margaretha
- * */
+ */
 public class SpanAttributeQueryWrapper extends SpanQueryWrapper {
 
     private SpanQueryWrapper subquery;
diff --git a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanClassQueryWrapper.java b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanClassQueryWrapper.java
index 51d4ab7..c06194f 100644
--- a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanClassQueryWrapper.java
+++ b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanClassQueryWrapper.java
@@ -70,8 +70,8 @@
         if (this.subquery.isNull())
             return (SpanQuery) null;
 
-        SpanQuery sq = (SpanQuery) this.subquery
-                .retrieveNode(this.retrieveNode).toFragmentQuery();
+        SpanQuery sq = (SpanQuery) this.subquery.retrieveNode(this.retrieveNode)
+                .toFragmentQuery();
 
         if (sq == null)
             return (SpanQuery) null;
diff --git a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanExpansionQueryWrapper.java b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanExpansionQueryWrapper.java
index 7c4cf61..f4011c2 100644
--- a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanExpansionQueryWrapper.java
+++ b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanExpansionQueryWrapper.java
@@ -8,7 +8,6 @@
 import de.ids_mannheim.korap.query.SpanExpansionQuery;
 import de.ids_mannheim.korap.util.QueryException;
 
-
 import java.util.*;
 
 /*
@@ -21,48 +20,41 @@
 public class SpanExpansionQueryWrapper extends SpanQueryWrapper {
     private SpanQueryWrapper anchor;
 
-	// < 0 	to the left of anchor span 
+    // < 0 	to the left of anchor span 
     // >= 0  to the right of anchor span
-	private int direction;
+    private int direction;
 
-	// if > 0, collect expansion offsets
-	// using this label
+    // if > 0, collect expansion offsets
+    // using this label
     private byte classNumber;
 
 
-    public SpanExpansionQueryWrapper (SpanQueryWrapper anchor,
-									  int min,
-									  int max,
-									  int direction,
-									  byte classNumber
-		) {
-		this.anchor = anchor;
-		this.isNull = false;
-		this.min = min;
-		this.max = max;
-		this.direction = direction;
-		this.classNumber = classNumber;
-		this.isExtended = true;
-		if (direction >= 0)
-			this.isExtendedToTheRight = true;
+    public SpanExpansionQueryWrapper (SpanQueryWrapper anchor, int min, int max,
+                                      int direction, byte classNumber) {
+        this.anchor = anchor;
+        this.isNull = false;
+        this.min = min;
+        this.max = max;
+        this.direction = direction;
+        this.classNumber = classNumber;
+        this.isExtended = true;
+        if (direction >= 0)
+            this.isExtendedToTheRight = true;
     };
 
-	@Override
+
+    @Override
     public boolean isNull () {
-		// Needs to be overwritten, as min and max do not indicate null value
+        // Needs to be overwritten, as min and max do not indicate null value
         return this.isNull;
     };
-	
 
-	@Override
+
+    @Override
     public SpanQuery toFragmentQuery () throws QueryException {
-		return new SpanExpansionQuery(
-			this.anchor.retrieveNode(this.retrieveNode).toFragmentQuery(),
-			this.getMin(),
-			this.getMax(),
-			this.direction,
-			this.classNumber,
-			true
-			);
+        return new SpanExpansionQuery(
+                this.anchor.retrieveNode(this.retrieveNode).toFragmentQuery(),
+                this.getMin(), this.getMax(), this.direction, this.classNumber,
+                true);
     };
 };
diff --git a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanFocusQueryWrapper.java b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanFocusQueryWrapper.java
index 8fadb3e..89d8f65 100644
--- a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanFocusQueryWrapper.java
+++ b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanFocusQueryWrapper.java
@@ -52,8 +52,9 @@
     public SpanQuery toFragmentQuery () throws QueryException {
         if (this.subquery.isNull())
             return (SpanQuery) null;
-        return new SpanFocusQuery(this.subquery.retrieveNode(this.retrieveNode)
-                .toFragmentQuery(), this.number);
+        return new SpanFocusQuery(
+                this.subquery.retrieveNode(this.retrieveNode).toFragmentQuery(),
+                this.number);
     };
 
 
diff --git a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanQueryWrapper.java b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanQueryWrapper.java
index f0221d5..c6e1355 100644
--- a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanQueryWrapper.java
+++ b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanQueryWrapper.java
@@ -95,8 +95,8 @@
         return this.isOptional;
     };
 
-	
-	public SpanQueryWrapper isOptional (boolean opt) {
+
+    public SpanQueryWrapper isOptional (boolean opt) {
         this.isOptional = opt;
         return this;
     };
@@ -219,6 +219,7 @@
         return this;
     };
 
+
     /**
      * Check, if the wrapped query can be used as an
      * anchor query in a sequence, i.e. a query that
@@ -419,10 +420,10 @@
      */
     public String toString () {
         String string = "" + (this.isNull() ? "isNull" : "notNull") + "-"
-			+ (this.isEmpty() ? "isEmpty" : "notEmpty") + "-"
-			+ (this.isOptional() ? "isOptional" : "notOptional") + "-"
-			+ (this.isExtendedToTheRight() ? "isExtendedToTheRight" : "notExtendedToTheRight");
-		;
+                + (this.isEmpty() ? "isEmpty" : "notEmpty") + "-"
+                + (this.isOptional() ? "isOptional" : "notOptional") + "-"
+                + (this.isExtendedToTheRight() ? "isExtendedToTheRight"
+                        : "notExtendedToTheRight");;
         return string;
     };
 };
diff --git a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanRepetitionQueryWrapper.java b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanRepetitionQueryWrapper.java
index 65c4da6..808b064 100644
--- a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanRepetitionQueryWrapper.java
+++ b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanRepetitionQueryWrapper.java
@@ -101,8 +101,9 @@
                     .toFragmentQuery();
 
         // That's a fine repetition query
-        return new SpanRepetitionQuery(this.subquery.retrieveNode(
-                this.retrieveNode).toFragmentQuery(), this.min, this.max, true);
+        return new SpanRepetitionQuery(
+                this.subquery.retrieveNode(this.retrieveNode).toFragmentQuery(),
+                this.min, this.max, true);
     };
 
 
diff --git a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanSegmentQueryWrapper.java b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanSegmentQueryWrapper.java
index 1b1929b..8623671 100644
--- a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanSegmentQueryWrapper.java
+++ b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanSegmentQueryWrapper.java
@@ -196,7 +196,8 @@
 
 
     public SpanQuery toFragmentQuery () throws QueryException {
-        if (this.isNull || (this.inclusive.size() + this.exclusive.size() == 0)) {
+        if (this.isNull
+                || (this.inclusive.size() + this.exclusive.size() == 0)) {
             return (SpanQuery) null;
         }
         else if (this.inclusive.size() >= 1 && this.exclusive.size() >= 1) {
diff --git a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanSequenceQueryWrapper.java b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanSequenceQueryWrapper.java
index c5aac76..2a263a6 100644
--- a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanSequenceQueryWrapper.java
+++ b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanSequenceQueryWrapper.java
@@ -89,8 +89,8 @@
     public SpanSequenceQueryWrapper (String field, String ... terms) {
         this(field);
         for (int i = 0; i < terms.length; i++) {
-            this.segments.add(new SpanSimpleQueryWrapper(new SpanTermQuery(
-                    new Term(field, terms[i]))));
+            this.segments.add(new SpanSimpleQueryWrapper(
+                    new SpanTermQuery(new Term(field, terms[i]))));
         };
         // Query can't be null anymore
         this.isNull = false;
@@ -133,8 +133,8 @@
         if (DEBUG) {
             if (!sswq.isEmpty()) {
                 try {
-                    log.trace("New span sequence {}", sswq.toFragmentQuery()
-                            .toString());
+                    log.trace("New span sequence {}",
+                            sswq.toFragmentQuery().toString());
                 }
                 catch (QueryException qe) {
                     log.trace("Unable to serialize query {}", qe.getMessage());
@@ -392,8 +392,8 @@
             this.constraints = new ArrayList<DistanceConstraint>(1);
         if (DEBUG)
             log.trace("With contraint {}-{} (excl {})", min, max, exclusion);
-        this.constraints.add(new DistanceConstraint(min, max, this.isInOrder,
-                exclusion));
+        this.constraints.add(
+                new DistanceConstraint(min, max, this.isInOrder, exclusion));
         return this;
     };
 
@@ -476,8 +476,8 @@
             String unit, boolean exclusion) {
 
         if (DEBUG)
-            log.trace("With contraint {}-{} (unit {}, excl {})", min, max,
-                    unit, exclusion);
+            log.trace("With contraint {}-{} (unit {}, excl {})", min, max, unit,
+                    exclusion);
 
         // Word unit
         if (unit.equals("w")) {
@@ -486,15 +486,15 @@
             if (this.constraints == null)
                 this.constraints = new ArrayList<DistanceConstraint>(1);
 
-            this.constraints.add(new DistanceConstraint(min, max, isInOrder,
-                    exclusion));
+            this.constraints.add(
+                    new DistanceConstraint(min, max, isInOrder, exclusion));
 
             return this;
         };
 
         // Element unit (sentence or paragraph)
-        return this.withConstraint(min, max, new SpanElementQueryWrapper(
-                this.field, unit), exclusion);
+        return this.withConstraint(min, max,
+                new SpanElementQueryWrapper(this.field, unit), exclusion);
     };
 
 
@@ -545,9 +545,10 @@
         // Element unit (sentence or paragraph)
         // Todo: This should possibly be evaluated to a query later on!
         try {
-            this.constraints.add(new DistanceConstraint((SpanElementQuery) unit
-                    .retrieveNode(this.retrieveNode).toFragmentQuery(), min,
-                    max, isInOrder, exclusion));
+            this.constraints.add(new DistanceConstraint(
+                    (SpanElementQuery) unit.retrieveNode(this.retrieveNode)
+                            .toFragmentQuery(),
+                    min, max, isInOrder, exclusion));
         }
         catch (QueryException qe) {
             this.constraintException = qe;
@@ -741,7 +742,7 @@
             return (SpanQuery) query;
         };
 
-		// DistanceQueries with problems
+        // DistanceQueries with problems
         if (this.hasConstraints() && this.isProblematic) {
             throw new QueryException(613,
                     "Distance constraints not supported with empty, optional or negative operands");
@@ -769,8 +770,8 @@
                     if (sq == null)
                         continue;
 
-                    SpanDistanceQuery sdquery = new SpanDistanceQuery(query,
-                            sq, constraint, true);
+                    SpanDistanceQuery sdquery = new SpanDistanceQuery(query, sq,
+                            constraint, true);
                     query = (SpanQuery) sdquery;
                 };
             }
@@ -793,8 +794,8 @@
                     if (sq == null)
                         continue;
 
-                    SpanDistanceQuery sdquery = new SpanDistanceQuery(query,
-                            sq, constraint, true);
+                    SpanDistanceQuery sdquery = new SpanDistanceQuery(query, sq,
+                            constraint, true);
                     query = (SpanQuery) sdquery;
                 };
             };
@@ -828,12 +829,12 @@
       segments to extensions).
       This has to be done as long as there are problematic segments
       In the queries.
-
+    
       While there is a segment isNegative() or isOptional() or isEmpty() do
       - look for an anchor next to it
       - merge the problematic segment with the anchor
       - go on
-
+    
       - This does not work for distance constraints!
     */
     private boolean _solveProblematicSequence () {
@@ -875,8 +876,7 @@
 
                     // Insert the solution
                     try {
-                        this.segments.set(
-                                i + 1,
+                        this.segments.set(i + 1,
                                 _merge(this.segments.get(i + 1), underScrutiny,
                                         false));
                     }
@@ -906,10 +906,8 @@
 
                     // Insert the solution
                     try {
-                        this.segments.set(
-                                i - 1,
-                                _merge(this.segments.get(i - 1), underScrutiny,
-                                        true));
+                        this.segments.set(i - 1, _merge(
+                                this.segments.get(i - 1), underScrutiny, true));
                     }
                     catch (QueryException e) {
                         this.isSolved = true;
@@ -969,8 +967,8 @@
         int direction = mergeLeft ? 1 : -1;
 
         if (DEBUG)
-            log.trace("Will merge two spans to {}", mergeLeft ? "left"
-                    : "right");
+            log.trace("Will merge two spans to {}",
+                    mergeLeft ? "left" : "right");
 
         // Make empty extension to anchor
         if (problem.isEmpty()) {
@@ -980,46 +978,44 @@
                 log.trace("Problem is empty with class {}",
                         problem.getClassNumber());
 
-			// Merge extensions!
-			if (!problem.hasClass() &&
-				!anchor.hasClass() &&
-				anchor.isExtended()) {
+            // Merge extensions!
+            if (!problem.hasClass() && !anchor.hasClass()
+                    && anchor.isExtended()) {
 
-				if (DEBUG)
-					log.trace("It may be possible to extend anchor with problem");
-				
-				if (
-					// Further extend to the right ...
-					(direction >= 0 && anchor.isExtendedToTheRight) ||
+                if (DEBUG)
+                    log.trace(
+                            "It may be possible to extend anchor with problem");
 
-					// or the left
-					(direction < 0 && !anchor.isExtendedToTheRight)) {
+                if (
+                // Further extend to the right ...
+                (direction >= 0 && anchor.isExtendedToTheRight) ||
 
-					if (DEBUG)
-						log.trace("Readjust min and max");
+                // or the left
+                        (direction < 0 && !anchor.isExtendedToTheRight)) {
 
-					// Readjust the anchor
-					anchor.setMin(anchor.getMin() + problem.getMin());
-					anchor.setMax(anchor.getMax() + problem.getMax());
+                    if (DEBUG)
+                        log.trace("Readjust min and max");
 
-					/*
-					 * This is wrong - min is only relevant for extensions
-					if (anchor.getMin() > 0)
-						anchor.isOptional = false;
-					*/					
-					return anchor;
-				};
-			};
+                    // Readjust the anchor
+                    anchor.setMin(anchor.getMin() + problem.getMin());
+                    anchor.setMax(anchor.getMax() + problem.getMax());
 
-			// Can't merge extensions
-			SpanQueryWrapper sqw = new SpanExpansionQueryWrapper(
-				anchor,
-				problem.isOptional() ? 0 : problem.getMin(),
-				problem.getMax(),
-				direction,
-				problem.hasClass() ? problem.getClassNumber() : (byte) 0
-				).isExtended(true);
-				
+                    /*
+                     * This is wrong - min is only relevant for extensions
+                    if (anchor.getMin() > 0)
+                    	anchor.isOptional = false;
+                    */
+                    return anchor;
+                };
+            };
+
+            // Can't merge extensions
+            SpanQueryWrapper sqw = new SpanExpansionQueryWrapper(anchor,
+                    problem.isOptional() ? 0 : problem.getMin(),
+                    problem.getMax(), direction,
+                    problem.hasClass() ? problem.getClassNumber() : (byte) 0)
+                            .isExtended(true);
+
             // Set right extension
             if (direction >= 0)
                 sqw.isExtendedToTheRight(true);
@@ -1036,17 +1032,17 @@
                 log.trace("Problem is negative with class {}",
                         problem.getClassNumber());
 
-			// TODO: Should probably wrapped as well!
-			// A sequence of negative tokens may expand jointly!
-			query = new SpanExpansionQuery(anchor.retrieveNode(
-											   this.retrieveNode).toFragmentQuery(), problem.retrieveNode(
-												   this.retrieveNode).toFragmentQuery(), problem.getMin(),
-										   problem.getMax(), direction,
-										   problem.hasClass() ? problem.getClassNumber() : (byte) 0,
-										   true);
+            // TODO: Should probably wrapped as well!
+            // A sequence of negative tokens may expand jointly!
+            query = new SpanExpansionQuery(
+                    anchor.retrieveNode(this.retrieveNode).toFragmentQuery(),
+                    problem.retrieveNode(this.retrieveNode).toFragmentQuery(),
+                    problem.getMin(), problem.getMax(), direction,
+                    problem.hasClass() ? problem.getClassNumber() : (byte) 0,
+                    true);
 
             SpanQueryWrapper sqw = new SpanSimpleQueryWrapper(query)
-				.isExtended(true);
+                    .isExtended(true);
 
             // Set right extension
             if (direction >= 0)
@@ -1058,29 +1054,25 @@
         if (DEBUG)
             log.trace("Problem is optional");
 
-		// [base=der][][base=Baum]?
+        // [base=der][][base=Baum]?
         // [base=der][base=baum]?
 
         // [base=der]
-        SpanAlterQueryWrapper saqw = new SpanAlterQueryWrapper(
-			this.field,
-			anchor
-			);
+        SpanAlterQueryWrapper saqw = new SpanAlterQueryWrapper(this.field,
+                anchor);
 
         // [base=der]
-        SpanSequenceQueryWrapper ssqw = new SpanSequenceQueryWrapper(
-			this.field,
-			anchor
-			);
+        SpanSequenceQueryWrapper ssqw = new SpanSequenceQueryWrapper(this.field,
+                anchor);
 
         // [base=der][base=baum]
-	    if (mergeLeft) {
+        if (mergeLeft) {
             ssqw.append(problem.isOptional(false));
-		}
+        }
         // [base=baum][base=der]
         else {
             ssqw.prepend(problem.isOptional(false));
-		}
+        }
 
         saqw.or(ssqw);
 
diff --git a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanSimpleQueryWrapper.java b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanSimpleQueryWrapper.java
index 3d9c76a..cdf4619 100644
--- a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanSimpleQueryWrapper.java
+++ b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanSimpleQueryWrapper.java
@@ -26,18 +26,20 @@
         this.query = query;
     };
 
-	// This is similar to a clone
-	public SpanSimpleQueryWrapper (SpanQueryWrapper query) throws QueryException {
-		this.hasClass = query.hasClass();
-		this.isOptional = query.isOptional();
-		this.isNegative = query.isNegative();
-		this.isEmpty = query.isEmpty();
-		this.isExtended = query.isExtended();
-		this.isExtendedToTheRight = query.isExtendedToTheRight();
-		this.maybeUnsorted = query.maybeUnsorted();
-		this.retrieveNode = query.retrieveNode;
-		this.query = query.toFragmentQuery();
-		this.isNull = query.isNull();
+
+    // This is similar to a clone
+    public SpanSimpleQueryWrapper (SpanQueryWrapper query)
+            throws QueryException {
+        this.hasClass = query.hasClass();
+        this.isOptional = query.isOptional();
+        this.isNegative = query.isNegative();
+        this.isEmpty = query.isEmpty();
+        this.isExtended = query.isExtended();
+        this.isExtendedToTheRight = query.isExtendedToTheRight();
+        this.maybeUnsorted = query.maybeUnsorted();
+        this.retrieveNode = query.retrieveNode;
+        this.query = query.toFragmentQuery();
+        this.isNull = query.isNull();
     };
 
 
diff --git a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanSubspanQueryWrapper.java b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanSubspanQueryWrapper.java
index d311a27..7e91844 100644
--- a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanSubspanQueryWrapper.java
+++ b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanSubspanQueryWrapper.java
@@ -25,7 +25,8 @@
 
 
     public SpanSubspanQueryWrapper (SpanQueryWrapper sqw, int startOffset,
-                                    int length) throws QueryException {
+                                    int length)
+            throws QueryException {
         if (length < 0) {
             throw new QueryException(
                     "SpanSubspanQuery cannot have length less than 0.");
diff --git a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanWithAttributeQueryWrapper.java b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanWithAttributeQueryWrapper.java
index 435b3ee..266e051 100644
--- a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanWithAttributeQueryWrapper.java
+++ b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanWithAttributeQueryWrapper.java
@@ -15,7 +15,7 @@
  * No optimization using expansion
  * 
  * @author margaretha
- * */
+ */
 public class SpanWithAttributeQueryWrapper extends SpanQueryWrapper {
 
     private SpanQueryWrapper withIdQueryWrapper = null;
@@ -33,7 +33,8 @@
             return;
         }
         if (attrQuery.isNegative) {
-            throw new QueryException("The query requires a positive attribute.");
+            throw new QueryException(
+                    "The query requires a positive attribute.");
         }
         this.attrQueryWrapper = attrQuery;
         this.isSingleAttribute = true;
@@ -153,7 +154,8 @@
 
     private SpanWithAttributeQuery createSpanWithSingleAttributeQuery (
             SimpleSpanQuery withIdQuery) throws QueryException {
-        SpanAttributeQuery attrQuery = createSpanAttributeQuery(this.attrQueryWrapper);
+        SpanAttributeQuery attrQuery = createSpanAttributeQuery(
+                this.attrQueryWrapper);
         if (attrQuery != null) {
             if (withIdQuery != null) {
                 return new SpanWithAttributeQuery(withIdQuery, attrQuery, true);
diff --git a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanWithinQueryWrapper.java b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanWithinQueryWrapper.java
index dc1f449..576b1e0 100644
--- a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanWithinQueryWrapper.java
+++ b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanWithinQueryWrapper.java
@@ -96,9 +96,10 @@
 
         // TODO: if (wrap.isNegative())
 
-        return new SpanWithinQuery(this.element.retrieveNode(this.retrieveNode)
-                .toFragmentQuery(), this.wrap.retrieveNode(this.retrieveNode)
-                .toFragmentQuery(), this.flag);
+        return new SpanWithinQuery(
+                this.element.retrieveNode(this.retrieveNode).toFragmentQuery(),
+                this.wrap.retrieveNode(this.retrieveNode).toFragmentQuery(),
+                this.flag);
     };