refactored application_controller