server: refactor server