refactor app to server