refactored all the server files