refactored server