refactoring json calls