handle JSON.parse() errors more gracefully