optimized replaceChild function's robustness !