 
     func addChange(change: ChangeModel) {
         if var changes = changes[change.documentPath] {
-            let intersectRange = intersect(change)
+            let intersectChange = intersect(change)
 
-            if (intersectRange.location > 0 && intersectRange.location > 0) {
-                
+            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

        }
    }

    func intersect(change: ChangeModel) -> NSRange {
        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 oldChange
            }
        }

        return nil
    }

}
