implemented method to merge the repeated names