updated write() function on FSM in client and server, missing testing