added check for missing keys (fixed)