factored out the format handling method in base_controller