refactored code and json