refactor should_retry
update docs