ADDED curl error check