bugfix max_retries hardcoded to 3