cleaned up the json handling to ensure send the content type right at beginning