refactor for logResponse()