         unless keypoint.count then return
         [kStart, kEnd] = keypoint.textOffsets[0]
         locationTerritory = _.find locTerritories, ({territoryStart, territoryEnd})->
-          if kEnd <= territoryEnd and kStart >= territoryStart
+          if kStart <= territoryEnd and kStart >= territoryStart
             return true
         dateTerritory = _.find dateTerritories, ({territoryStart, territoryEnd})->
-          if kEnd <= territoryEnd and kStart >= territoryStart
+          if kStart <= territoryEnd and kStart >= territoryStart
             return true
         incident =
-          timeRange: {}
           locations: locationTerritory.annotations.map(({location})->geonamesById[location.geonameid])
         mostFromKeys = 0
         mostToKeys = 0

          if not time.timeRange
            #console.log "No Timerange", annotation
            return
          fromTime = time.timeRange.begin
          if fromTime
            fromKeys = Object.keys(fromTime).length
            parsedDate = moment(fromTime)
            if fromKeys > mostFromKeys and parsedDate.isValid()
              incident.timeRange.start = parsedDate.toDate()
              mostFromKeys = fromKeys
          toTime = time.timeRange.end
          if toTime
            toKeys = Object.keys(toTime).length
            # Round up the to date
            parsedDate = moment(_.extend({hours:23, minutes: 59}, toTime))
            if toKeys > mostToKeys and parsedDate.isValid()
              incident.timeRange.end = parsedDate.toDate()
              mostToKeys = toKeys
        incident.dateTerritory = dateTerritory
        incident.locationTerritory = locationTerritory
        incident.countAnnotation = keypoint

      else
        sentAnnotations.push annotation
        annotationIdx++
    if sentAnnotations.length > 0 or territories.length == 0
      territories.push
        annotations: sentAnnotations
        territoryStart: sentStart
        territoryEnd: sentEnd
    else
      territories[territories.length - 1].territoryEnd = sentEnd
  return territories

# Parse text into an array of sentences separated by
# periods, colons, semi-colons, or double linebreaks.
parseSents = (text)->
  idx = 0
  sents = []
  sentStart = 0
  while idx < text.length
    char = text[idx]
    if char == "\n"
      [match] = text.slice(idx).match(/^\n+/)
      idx += match.length
      if match.length > 1
        sents[sents.length] = text.slice(sentStart, idx)
        sentStart = idx
    else if /^[\.\;\:]/.test(char)
      idx++
      sents[sents.length] = text.slice(sentStart, idx)
      sentStart = idx
    else
      idx++
  return sents

Template.suggestedIncidentsModal.onCreated ->
  @incidentCollection = new Meteor.Collection(null)
