Refactored http request and response as per comments