fixing a bug in the child indexing