Fixed cost bug.

Change-Id: Ia6c8fc60a3b07fcf709edd35e797232d87da41f0
diff --git a/src/main/java/de/ids_mannheim/korap/query/spans/TokenDistanceSpans.java b/src/main/java/de/ids_mannheim/korap/query/spans/TokenDistanceSpans.java
index 9044c5e..8d427d7 100644
--- a/src/main/java/de/ids_mannheim/korap/query/spans/TokenDistanceSpans.java
+++ b/src/main/java/de/ids_mannheim/korap/query/spans/TokenDistanceSpans.java
@@ -125,8 +125,16 @@
 
     @Override
     public long cost () {
-        CandidateSpan candidateSpan = candidateList.get(candidateListIndex);
-        return candidateSpan.getCost() + secondSpans.cost();
+		if (candidateList.size() > 0) {
+			long cost = 0;
+			for (CandidateSpan candidateSpan : candidateList) {
+				cost += candidateSpan.getCost();
+			}
+			return cost + secondSpans.cost();
+        }
+        else {
+			return firstSpans.cost() + secondSpans.cost();
+		}
     }