Refactor json responses