updated code for client-server without encapsulation