updated retry mechanism to use retry block