Updated cost (fixed the bug).

Change-Id: I3b986edbc9a8506ec4b4e84464df697d5dcfb371
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 7eb0dfc..e4b5d1b 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,15 @@
 
     @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();
+		}
     }