refactoring json query