code for client