handle html & json responses