         var previousRelationship : Relationship! = nil;
         var nextRelationship : Relationship! = nil;
         
-        var nextRelationshipID = aRelationship.endNodeNextRelationID
-        var previousRelationshipID = aRelationship.endNodePreviousRelationID
+        let nextRelationshipID = aRelationship.endNodeNextRelationID
+        let previousRelationshipID = aRelationship.endNodePreviousRelationID
         
         if (nextRelationshipID > 0) {
             nextRelationship = context!.readRelationship(nextRelationshipID)

            endNode.insertInRelationship(relationship)
            
            //NSMutableArray *outRelationships = [self outRelationshipArray];
            var outRelationships = self.outRelationships
            
            //SORelationship *lastRelationship = [outRelationships lastObject];
            var lastRelationship = outRelationships.last
            
            // TODO: optional chaining?
            if (lastRelationship != nil) {

            self.update()
        }
        
        //let index = find(outRelationships, aRelationship)// init outRelationships in worst case
        let index = outRelationships.indexOf(aRelationship)
        if let index = index {
            _outRelationships.removeAtIndex(index)
        }
    }


