client lib refactor