Refactor logic in json walker a little bit