implementing withOffsets in document terms