Fixed retry logic - needed to use a <= rather than < in the for loop so that once the final retry sleep had executed, the last retry would run. Also added an internal retry count evaluator so that if the final retry fails, it does not then wait for X amount of seconds before returning the exception.