minor refactor of client.ts