improve shadow element handling