Clean and uniqueid logic