merge with v2
refactor retry function and pep8
reverse after before argument
reverse after before argument