refactor client code.