moved curl functionality into request function