server code restructure