refactoring reading json