Refactor client