did not find the json.stringify bug, but a typo at Delete(val, I) which was Delete(val, P) and deleted useless variables