refactor client functionality