Refactor curl related procedure.