refactor server class