bug fix for relationship code

Hi,

I have fixed the code as we discussed yesterday.