rewriting server code