trying to refactor json stuff