added null check for inverse relationships