update code for fall back on failed api connection