updated addIfNew and remove code