fix bug(when index==-1 for relationship)