refactored relationship finding code into datasource