server: refactor