use JSONObject and add error logging