added exception handling to making the json
added itemgetter (not sure if this is used
but was in example)