Cleaning up code and moved json string decoding to json.load from ast