First version of the checking code for replacement