adding check for user agent and json responses