basic functionality of remove duplicates
correct bug for returning and add case of duplicates of the last item