begin refactor of client.py