changed function. now works with new JSON