improve server code after review