rewrite client.py