moved out gotoroot and expanded it to check