update the script to not call the jsonctmctree function repeatedly