confirm that data is in fact an object before attempting to read keys