fixed issues when duplicate references