Updated to throw exception when curl fails