implementing read/write with server

still a little buggy