added check for missing keys