sample server refactoring