Added support for handling duplicates.