added removal of duplicate elements