added some code to handle dead children