refactor client+server