cleanup json code
updated to reflect feedback