Less cluttered pre-replacement function.