rafactoring the server client