Improved deleteChild method, to be more stable