set elementRef for empty attributes
diff --git a/src/main/java/de/ids_mannheim/korap/query/spans/AttributeSpans.java b/src/main/java/de/ids_mannheim/korap/query/spans/AttributeSpans.java
index 52439a6..7f57290 100644
--- a/src/main/java/de/ids_mannheim/korap/query/spans/AttributeSpans.java
+++ b/src/main/java/de/ids_mannheim/korap/query/spans/AttributeSpans.java
@@ -15,13 +15,12 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import de.ids_mannheim.korap.query.SimpleSpanQuery;
 import de.ids_mannheim.korap.query.SpanAttributeQuery;
 
 /** Span enumeration of attributes which are treated as a normal term with 
  * 	special payload assignment referring to to which element it belongs.  
  * 	The class is basically a wrapper of the TermSpan with additional 
- * 	functionality regarding the element reference. Element reference is 
+ * 	functionality regarding element reference. Element reference is 
  * 	annotated ascendingly starting from the left side.
  * 
  * 	The enumeration is ordered firstly by the start position of the attribute 
diff --git a/src/main/java/de/ids_mannheim/korap/query/spans/ElementAttributeSpans.java b/src/main/java/de/ids_mannheim/korap/query/spans/ElementAttributeSpans.java
index dc23d7b..f6b72da 100644
--- a/src/main/java/de/ids_mannheim/korap/query/spans/ElementAttributeSpans.java
+++ b/src/main/java/de/ids_mannheim/korap/query/spans/ElementAttributeSpans.java
@@ -44,6 +44,14 @@
 		while (hasMoreSpans && ensureSamePosition(elements,attributes)){ 
 			
 			logger.info("element: " + elements.start() + ","+ elements.end() +" ref:"+elements.getElementRef());
+			
+			if (elements.getElementRef() < 1){
+				elements.isElementRef = true; // dummy setting enabling reading elementRef
+				hasMoreSpans = elements.next();
+				logger.info("skip");
+				continue;
+			}
+			
 			logger.info("attribute {} ref:{}", attributes.start(),  attributes.getElementRef());
 			
 			if (elements.getElementRef() == attributes.getElementRef()){
diff --git a/src/main/java/de/ids_mannheim/korap/query/spans/ElementSpans.java b/src/main/java/de/ids_mannheim/korap/query/spans/ElementSpans.java
index 7ef8928..c2a6da1 100644
--- a/src/main/java/de/ids_mannheim/korap/query/spans/ElementSpans.java
+++ b/src/main/java/de/ids_mannheim/korap/query/spans/ElementSpans.java
@@ -321,7 +321,7 @@
 			else{
 				// Copy rest of payloads after the end position
 				this.current.payload.put(payload.bytes, payload.offset + 12, payload.length - 12);
-				this.current.elementRef = 0;
+				this.current.elementRef = -1;
 			}
 	    }
 	    else {	
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestAttributeIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestAttributeIndex.java
index cae40aa..def6a49 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestAttributeIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestAttributeIndex.java
@@ -34,12 +34,14 @@
 		fd.addString("ID", "doc-0");
 		fd.addTV("base",
 			 "bcbabd",			 
-			 "[(0-1)s:b|_1#0-1|<>:s#0-5$<i>5<s>1|<>:div#0-3$<i>3<s>2|<>:div#0-2$<i>2<s>3|@:class=header$<s>2|@:class=header$<s>3]" +
+			 "[(0-1)s:b|_1#0-1|<>:s#0-5$<i>5<s>-1|<>:div#0-3$<i>3<s>1|<>:div#0-2$<i>2<s>2|@:class=header$<s>1|@:class=header$<s>2]" +
 			 "[(1-2)s:c|_2#1-2|<>:a#1-2$<i>2<s>1|@:class=header$<s>1]" +			 
 			 "[(2-3)s:b|_3#2-3|<>:div#2-3$<i>5<s>1|@:class=time$<s>1]" +
 			 "[(3-4)s:a|_4#3-4|<>:div#3-5$<i>5<s>1|@:class=header$<s>1]" + 
-			 "[(4-5)s:b|_5#4-5|<>:div#4-5$<i>5<s>1|<>:a#4-5$<i>5<s>2|@:class=header$<s>2]" +			 
-			 "[(5-6)s:d|_6#5-6|<>:s#5-6$<i>6<s>2|<>:div#5-6$<i>6<s>1|@:class=header$<s>1|@:class=header$<s>2]");
+			 "[(4-5)s:b|_5#4-5|<>:div#4-5$<i>5<s>1|<>:a#4-5$<i>5<s>2|@:class=header$<s>2]" +
+			 "[(5-6)s:d|_6#5-6|<>:s#5-6$<i>6<s>1|<>:div#5-6$<i>6<s>-1|@:class=header$<s>1]"+
+			 "[(6-7)s:d|_7#6-7|<>:s#6-7$<i>7<s>2|<>:div#6-7$<i>7<s>1|@:class=header$<s>1|@:class=header$<s>2]");
+			 
 		return fd;
 	}
 	
@@ -63,8 +65,8 @@
 		assertEquals(3,kr.getMatch(1).getEndPos());
 		assertEquals(3,kr.getMatch(2).getStartPos());
 		assertEquals(5,kr.getMatch(2).getEndPos());
-		assertEquals(5,kr.getMatch(3).getStartPos());
-		assertEquals(6,kr.getMatch(3).getEndPos());
+		assertEquals(6,kr.getMatch(3).getStartPos());
+		assertEquals(7,kr.getMatch(3).getEndPos());
 	}