Refactoring on AppController.