add error handling, with json'd response