moved server logic into separate module