Move curl to its own function