added proper json error handling