simplify
refactor, eliminate redundancy in i/o retry loops