refactor app controller