c copy replace but needs rework