refactored panels_controller to lower complexity