rewriting server code #3