retry logic when network fails