Put the relationship check in its own function