reworked both client and server