added support for duplicates