server refactored