added logic to check to see if relations exist before trying to create them