refactoring to json