Fixed write child code bug