refactoring json call