fixed parsing to json on undefined