fix bugs with replacechild