fixed foreach issue, found another bug in json code