improve handling of curl exec