Refactor code and add retry support, fixes #2
Merge pull request #3 from FriendCode/feature/retry

Refactor code and add retry support, fixes #2