refactored code for modified json input