Added guard against malformed JSON