added null check on API call, and recursive retry