separate into library and server