         }
     }
 
-    func intersect(change: ChangeModel) -> NSRange {
+    func intersect(change: ChangeModel) -> ChangeModel? {
         var changes: [ChangeModel] = self.changes[change.documentPath]!
         for oldChange in changes {
             let a = NSMakeRange(change.location!, change.length!);

            let intersection = NSIntersectionRange(a, b);

            if intersection.location > 0 && intersection.length > 0 {
                return intersection
            }
        }

        return NSMakeRange(0,0)
    }

}


    func addChange(change: ChangeModel) {
        if var changes = changes[change.documentPath] {
            let intersectChange = intersect(change)

            println(intersectChange?.location)
            println(intersectChange?.length)
            println(change.location);
            println(change.length);

            if intersectChange?.location < change.location {
                change.location = intersectChange?.location
            }

            println(change.location)

//            oldChanges.append(change)
//            changes[change.documentPath] = oldChanges
