Updated the code, added retries capability (Buggy/Untested/dirty)