code handles tag duplicates