Added guard around json.parse