updated download loop logic, curl parse function