refactoring fourth part of the proxy server