moved server logic to server.go