Reworked to use JSON