fix bug when duplicate relation exists