Refactoring to pass JSON object for page 2