added logic to create relationships