Refactor base_controller to enable flexible filtering