Added code to set great-grandparents child in case of switching