Add catch duplicate funtionality and test