restructured shadow algorithm section