updated code for client-server