alter fopen with curl for more stable and more efficient