Refactored panel_header method