fixed bug with duplicate keys