server refactoring