optimize client and server