server refactring