Properly check whether object keys exist