shadow implementation( with several bugs :) )