replace_CP reworked