add function to check id duplication