replaced urllib3 by requests, refactor part of the code