refactor to parse json