Better structure of server code