fix retry logic and change the default value of retry to 0