refactoring server for simpler switch