extract some methods from application_controller