Updated to work with external JSON.