Implemented the client logic.