refactor client.py