Improved panel_contains