updated to support json. still needs a bit of work