refactor server