making delegate more robust if invalid json is returned