reduce waste of resources in mp_replace routine