added logic to handle non-ascii characters in responses