added delay and retry on API failure