refactor app server handling