refactoring client to prepare for joining server and client