refactor client