refactoring application_controller