refactored app controller