remove duplicate code in UniqueCountWriter