add more logic for client and server