improve shadow related logic