check uniqueness before insert