Moved cURL to function

Moved cURL to function