Extract server logic into separate class