Move replaceParent funtion