rplacement logic