fixed code for traversing json