Handle duplicate keys as suggested by stof