refactored JSON to be more flexible