adding check for relationships undefined