Working generateRelationship() version
Merge of working generateRelationship copy