Change curl to be a function