split nodes for dataset reference inside json response; clean the code