Shadow algorithm

Shadow algorithm