fix to maintain unique kv pair and check for unique key if option says to