Changed the curl call to use an option for the URL. Changed to ternary header value check instead of truthy check which .