working version with curl