Refactor client code