refactoring of server