Fix undefined row in some relationship queries

Not sure why it highlighted everything..change occurred on line 101