rewritten to use requests module