json processing refactored