Rearrange http request function