Using a function to prevent crashing if curl'ed and stopped