Check key exists before using the value

This stops an annoying NOTICE in logs

Change-Id: I13e9f0fc2d1e42c70a6be53ddc3fd32d915860ff
Merge "Check key exists before using the value"