Added a check on the api key for duplicate keys