slight modification
json logic integrated